Class OLEFormat (Word VBA)

The class OLEFormat represents the OLE characteristics (other than linking) for an OLE object, ActiveX control, or field.

The main procedures of class OLEFormat are Activate and Open


To use a OLEFormat class variable it first needs to be instantiated, for example

Dim ole as OLEFormat
Set ole = ActiveDocument.Fields(1).OLEFormat

The following procedures can be used to set variables of type OLEFormat: Field.OLEFormat, InlineShape.OLEFormat and Shape.OLEFormat


These are the main methods of the OLEFormat class

Activate - Activates the specified OLEFormat object.


Open - Opens the specified OLEFormat object.


Other Methods

ConvertTo - Converts the specified OLE object from one class to another, making it possible for you to edit the object in a different server application or change how the object is displayed in the document.


DoVerb - Requests that an OLE object perform one of its available verbs—the actions an OLE object takes to activate its contents.



ClassType returns or sets the class type for the specified OLE object, picture, or field.

ActiveDocument.Fields(1).OLEFormat.ClassType =

DisplayAsIcon true if the specified object is displayed as an icon.

ActiveDocument.Fields(1).OLEFormat.DisplayAsIcon = True

IconIndex returns or sets the icon that is used when the DisplayAsIcon property is True.

ActiveDocument.Fields(1).OLEFormat.IconIndex =

IconLabel returns or sets the text displayed below the icon for an OLE object.

ActiveDocument.Fields(1).OLEFormat.IconLabel =

IconName returns or sets the program file in which the icon for an OLE object is stored.

ActiveDocument.Fields(1).OLEFormat.IconName =

IconPath returns the path of the file in which the icon for an OLE object is stored.

Dim strIconPath As String
strIconPath = ActiveDocument.Fields(1).OLEFormat.IconPath

Label returns a string that's used to identify the portion of the source file that's being linked.

Dim strLabel As String
strLabel = ActiveDocument.Fields(1).OLEFormat.Label

Object returns an object that represents the specified OLE object's top-level interface. .

Dim objObject As Object
Set objObject = ActiveDocument.Fields(1).OLEFormat.Object

Parent returns an object that represents the parent object of the specified OLEFormat object.

Dim objParent As Object
Set objParent = ActiveDocument.Fields(1).OLEFormat.Parent

PreserveFormattingOnUpdate true preserves formatting done in Microsoft Word to a linked OLE object, such as a table linked to a Microsoft Excel spreadsheet.

ActiveDocument.Fields(1).OLEFormat.PreserveFormattingOnUpdate = True

ProgID returns the programmatic identifier (ProgID) for the specified OLE object.

Dim strProgID As String
strProgID = ActiveDocument.Fields(1).OLEFormat.ProgID