AddOLEObject Method

See Also         Example         Applies To

Shapes object: Creates an OLE object. Returns the Shape object that represents the new OLE object.

InlineShapes object: Creates an OLE object. Returns the InlineShape object that represents the new OLE object.

Syntax 1

expression.AddOLEObject(ClassType, FileName, LinkToFile, DisplayAsIcon, IconFileName, IconIndex, IconLabel, Left, Top, Width, Height, Anchor)

Syntax 2

expression.AddOLEObject(ClassType, FileName, LinkToFile, DisplayAsIcon, IconFileName, IconIndex, IconLabel, Range)

expression   Syntax 1: Required. An expression that returns a Shapes object.

Syntax 2: Required. An expression that returns an InlineShapes object.

ClassType   Optional String. The name of the application used to activate the specified OLE object. You can see a list of the available applications in the Object type box on the Create New tab in the Object dialog box (Insert menu). You can find the ClassType string by inserting an object as an inline shape and then viewing the field codes. The class type of the object follows either the word "EMBED" or the word "LINK." You must specify either the ClassType or FileName argument for the object, but not both.

For information about available class types, see OLE Programmatic Identifiers.

FileName   Optional Variant. The file from which the object is to be created. If this argument is omitted, the current folder is used. You must specify either the ClassType or FileName argument for the object, but not both.

LinkToFile   Optional Variant. True to link the OLE object to the file from which it was created. False to make the OLE object an independent copy of the file. If you specified a value for ClassType, the LinkToFile argument must be False. The default value is False.

DisplayAsIcon   Optional Variant. True to display the OLE object as an icon. The default value is False.

IconFileName   Optional Variant. The file that contains the icon to be displayed.

IconIndex   Optional Variant. The index number of the icon within IconFileName. The order of icons in the specified file corresponds to the order in which the icons appear in the Change Icon dialog box (Insert menu, Object dialog box) when the Display as icon check box is selected. The first icon in the file has the index number 0 (zero). If an icon with the given index number doesn't exist in IconFileName, the icon with the index number 1 (the second icon in the file) is used. The default value is 0 (zero).

IconLabel   Optional Variant. A label (caption) to be displayed beneath the icon.

Left, Top   Optional Variant. The position (in points) of the upper-left corner of the new object relative to the anchor.

Width, Height   Optional Variant. The width and height of the OLE object, in points.

Anchor   Optional Variant. The range to which the OLE object is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph of the anchoring range. If Anchor is not specified, the anchor is placed automatically and the OLE Object is positioned relative to the top and left edges of the page.

Range   Optional Variant. The range where the OLE object will be placed in the text. The OLE object replaces the range, unless the range is collapsed. If this argument is omitted, the object is placed automatically.