AddOLEObject Method
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Adds a new Shape object representing an OLE object to the specified Shapes collection.
expression.AddOLEObject(Left, Top, Width, Height, ClassName, FileName, Link)
expression Required. An expression that returns one of the objects in the Applies To list.
Left Required Variant. The position of the left edge of the shape representing the OLE object.
Top Required Variant. The position of the top edge of the shape representing the OLE object.
Width Optional Variant. The width of the shape representing the OLE object. Default is -1, meaning that Microsoft Publisher automatically sets the width of the shape based on the object's data.
Height Optional Variant. The height of the shape representing the OLE object. Default is -1, meaning that Microsoft Publisher automatically sets the height of the shape based on the object's data.
ClassName Optional String. The class name of the OLE object to be added.
FileName Optional String. The file name of the OLE object to be added. If the path isn't specified, the current working folder is used.
MsoTriState
MsoTriState can be one of these MsoTriState constants. |
msoCTrue Not used for this method. |
msoFalse The OLE object is embedded. |
msoTriStateMixed Not used for this method. |
msoTriStateToggle Not used for this method. |
msoTruedefault The OLE object is linked. |
Remarks
For the Left, Top, Width, and Height arguments, numeric values are evaluated in points; strings can be in any units supported by Microsoft Publisher (for example, "2.5 in").
You must specify either a ClassName or FileName. If neither argument is specified or both are specified, an error occurs.
Example
The following example adds a Microsoft Excel worksheet to the first page of the active publication and activates the worksheet for editing.
`
Dim shpSheet As Shape`Set shpSheet = ActiveDocument.Pages(1).Shapes.AddOLEObject _ (Left:=72, Top:=72, ClassName:="Excel.Sheet")
shpSheet.OLEFormat.Activate