AddOLEObject Method

Applies To

Shapes collection object.

Description

Creates an OLE object. Returns a Shape object that represents the new OLE object.

Syntax

expression.AddOLEObject(Left, Top, Width, Height, ClassName, FileName,
ú DisplayAsIcon, IconFileName, IconIndex, IconLabel, Link)

expression Required. An expression that returns a Shapes object.

Left, Top Optional Single. The position (in points) of the upper-left corner of the new object relative to the upper-left corner of the slide. The default value is 0 (zero).

Width, Height Optional Single. The initial dimensions of the OLE object, in points.

ClassName Optional String. The OLE long class name or the ProgID for the object that's to be created. You must specify either the ClassName or FileName argument for the object, but not both.

FileName Optional String. The file from which the object is to be created. If the path isn't specified, the current working folder is used. You must specify either the ClassName or FileName argument for the object, but not both.

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

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

IconIndex Optional Long. The index 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 (accessed from the Insert 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 String. A label (caption) to be displayed beneath the icon.

Link Optional Long. 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 ClassName, this argument must be False. The default value is False.

See Also

AddMediaObject method, AddPicture method, ProgID property.

Example

This example adds a linked Word document to myDocument.

Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddOLEObject Left:=100, Top:=100, Width:=200, _
    Height:=300, FileName:="c:\my documents\testing.doc", link:=True
This example adds a new Microsoft Excel worksheet to myDocument. The worksheet will be displayed as an icon.

Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddOLEObject Left:=100, Top:=100, Width:=200, _
    Height:=300, ClassName:="Excel.Sheet.8", DisplayAsIcon:=True
This example adds a command button to myDocument.

Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddOLEObject Left:=100, Top:=100, Width:=150, _
    Height:=50, ClassName:="Forms.CommandButton.1"