Applies To
OLEObjects Collection.
Description
Adds a new OLE object to the current sheet. Returns an OLEObject object.
Syntax
object.Add(classType, fileName, link, displayAsIcon, iconFileName, iconIndex, iconLabel)
object
Required. The OLEObjects collection.
classType
Optional (you must specify either classType or fileName). A string containing the OLE long class name for the object that is to be created. If classType is specified, fileName and link are ignored.
fileName
Optional (you must specify either classType or fileName). A string specifying the file from which the OLE object is to be created.
link
Optional. True if the new OLE object based on fileName should be linked to that file. If it is not linked, the file is created as a copy of the file. False if omitted.
displayAsIcon
Optional. True if the new OLE object is displayed as an icon, or as its regular picture. If True, the iconFileName and iconIndex can be used to specify an icon.
iconFileName
Optional. A string that specifies the file that contains the icon to be displayed. This is used only if displayAsIcon is True. If not specified or the file contains no icons, the default icon for the OLE Class is used.
iconIndex
Optional. The number of the icon within the iconFileName. This is used only if displayAsIcon is True and iconFileName refers to a valid file containing icons. If an icon with the given index does not exist in the file specified in iconFileName, the first one in the file is used.
iconLabel
Optional. A string specifying a label to display beneath the icon. This is used only if displayAsIcon is True. If this argument is omitted or the string is empty (""), then no caption is displayed.
Example
This example creates a new Microsoft Word OLE object on Sheet1.
ActiveWorkbook.Worksheets("Sheet1").OLEObjects.Add _ classType:="Word.Document.6"