AddOLEObject Method

Microsoft Publisher Visual Basic

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 the width of the shape is automatically set based on the object's data.

Height   Optional Variant. The height of the shape representing the OLE object. Default is -1, meaning that the width of the shape is automatically set 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.

Link   Optional MsoTriState. Determines whether the OLE object is linked to or embedded in the publication.

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.
msoTrue default 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 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 an 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