Table of contents
TOC
Collapse the table of content
Expand the table of content

Shapes.AddOLEObject Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

Adds a new Shape object representing an OLE object to the specified Shapes collection.

Syntax

expression. AddOLEObject( Left, Top, Width, Height, ClassName, Filename, Link)

_expression_A variable that represents a Shapes object.

Parameters

NameRequired/OptionalData TypeDescription
LeftRequiredVariantThe position of the left edge of the shape representing the OLE object.
TopRequiredVariantThe position of the top edge of the shape representing the OLE object.
WidthOptionalVariantThe 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.
HeightOptionalVariantThe 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.
ClassNameOptionalStringThe class name of the OLE object to be added.
FilenameOptionalStringThe file name of the OLE object to be added. If the path is not specified, the current working folder is used.
LinkOptionalMsoTriStateDetermines whether the OLE object is linked to or embedded in the publication.

Return Value

Shape

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 if both are specified, an error occurs.

The Link parameter can be one of the MsoTriState constants declared in the Microsoft Office type library and shown in the following table.

ConstantDescription
msoFalseThe OLE object is embedded.
msoTrueThe OLE object is linked. The default.

Example

The following example adds a Microsoft Office 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
© 2018 Microsoft