Export (0) Print
Expand All

Shapes.AddOLEObject Method

Office 2007
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   A variable that represents a Shapes object.

Parameters

NameRequired/OptionalData TypeDescription
LeftOptionalSingleThe 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).
TopOptionalSingleThe 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).
WidthOptionalSingleThe initial width of the OLE object, in points.
HeightOptionalSingleThe initial height of the OLE object, in points.
ClassNameOptionalStringThe 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.
FileNameOptionalStringThe 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.
DisplayAsIconOptionalMsoTriStateDetermines whether the OLE object will be displayed as an icon.
IconFileNameOptionalStringThe file that contains the icon to be displayed.
IconIndexOptionalLongThe index of the icon within IconFileName. 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).
IconLabelOptionalStringA label (caption) to be displayed beneath the icon.
LinkOptionalMsoTriStateDetermines whether the OLE object will be linked to the file from which it was created. If you specified a value for ClassName, this argument must be msoFalse.

Return Value
Shape

Example

This example adds a linked Word document to myDocument.

Visual Basic for Applications
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddOLEObject Left:=100, Top:=100, _
    Width:=200, Height:=300, _
    FileName:="c:\my documents\testing.doc", Link:=msoTrue

This example adds a new Microsoft Office Excel worksheet to myDocument. The worksheet will be displayed as an icon.

Visual Basic for Applications
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddOLEObject Left:=100, Top:=100, _
    Width:=200, Height:=300, _
    ClassName:="Excel.Sheet", DisplayAsIcon:=True

This example adds a command button to myDocument.

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



Community Additions

ADD
Show:
© 2014 Microsoft