InsertObject method

Microsoft Visio Developer Reference

InsertObject method

   Example   

Adds a new embedded object or ActiveX control to a page, master, or group.

Version added

4.1

Syntax

objRet = object.InsertObject(ClassOrProgID, flags)

objRet

A Shape object that represents the newly created object or control.

object

Required. An expression that returns a Page, Master, or Shape object in which to create the object or control.

ClassOrProgID

Required String. Identifies the type of object or control to create.

flags

Required Integer. Flags that influence the operation.

Remarks

ClassOrProgID is a string that identifies the kind of object or control to create. It can be either the object or control's class ID (GUID) in string form or the object or control's program ID of the handler for the class.

  • If ClassOrProgID is a string representing a class ID, it looks like "{D3E34B21-9D75-101A-8C3D-00AA001A1652}."
  • If ClassOrProgID is a string representing a program ID, it looks like "paint.picture" or "forms.combobox.1".

See vendor-specific documentation or browse the registry to determine which class IDs and program IDs are associated with objects and controls provided by other applications.

The flags argument is a bit mask that can include one of the following values.

Constant

Value

Description

visInsertIcon

&H10

Display the new shape as an icon.

visInsertDontShow

&H1000

Don't execute the new object's show verb.

If both visInsertIcon and visInsertDontShow are specified, the InsertObject method fails. If you want to insert an object that is displayed as an icon, you must allow the application to execute the object's show verb.

The flags argument can also include one of the following values.

Constant

Value

visInsertAsControl

&H2000

visInsertAsEmbed

&H4000

Values in visInsertAsControl and visInsertAsEmbed only have an effect if the class identified by ClassOrProgID is identified in the registry as a control that can be inserted. If neither visInsertAsControl nor visInsertAsEmbed is specified and the object can be either a control or an embedded object, the application inserts it as a control.

In rare cases, Visio 5.0 or later versions may insert a control whereas earlier versions of Visio would have responded to the same call by inserting an embedded object. If a control is inserted, this method places the document in design mode, causing any code executing in the document to halt until the document is returned to run mode.