Creates an OLE object. Returns the InlineShape object that represents the new OLE object.
expression.AddOLEObject(ClassType, FileName, LinkToFile, DisplayAsIcon, IconFileName, IconIndex, IconLabel, Range)
expression Required. An expression that returns a InlineShapes object.
ClassType Optional Variant. The name of the application used to activate the specified OLE object.
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.
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.
AddOLEObject method as it applies to the Shapes object.
Creates an OLE object. Returns the Shape object that represents the new OLE object.
expression.AddOLEObject(ClassType, FileName, LinkToFile, DisplayAsIcon, IconFileName, IconIndex, IconLabel, Left, Top, Width, Height, Anchor)
expression Required. An expression that returns a Shapes object.
ClassType Optional Variant. The name of the application used to activate the specified OLE object.
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 Optional Variant. The position (in points) of the left edge of the new object relative to the anchor.
Top Optional Variant. The position (in points) of the upper edge of the new object relative to the anchor.
Width Optional Variant. The width of the OLE object, in points.
Height Optional Variant. The 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.
Example
As it applies to the Shapes object.
This example adds a new floating bitmap image to the active document. The bitmap is linked to another file.
ActiveDocument.Shapes.AddOLEObject _
FileName:="c:\my documents\MyDrawing.bmp", _
LinkToFile:=True
As it applies to the InlineShapes object.
This example adds a new Microsoft Excel worksheet to the active document at the second paragraph.
ActiveDocument.InlineShapes.AddOLEObject _
ClassType:="Excel.Sheet", DisplayAsIcon:=False, _
Range:=ActiveDocument.Paragraphs(2).Range