AddOLEControl 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.
AddOLEControl method as it applies to the InlineShapes object.
Creates an ActiveX control (formerly known as an OLE control). Returns the InlineShape object that represents the new ActiveX control.
expression.AddOLEControl(ClassType, Range)
expression Required. An expression that returns an InlineShapes object.
ClassType Optional Variant. The programmatic identifier for the ActiveX control to be created.
Range Optional Variant. The range where the ActiveX control will be placed in the text. The ActiveX control replaces the range, if the range isn't collapsed. If this argument is omitted, the Active X control is placed automatically.
AddOLEControl method as it applies to the Shapes object.
Creates an ActiveX control (formerly known as an OLE control). Returns the Shape object that represents the new ActiveX control.
expression.AddOLEControl(ClassType, Left, Top, Width, Height, Anchor)
expression Required. An expression that returns a Shapes object.
ClassType Optional Variant. The programmatic identifier for the ActiveX control to be created.
Left Optional Variant. The position (in points) of the left edge of the new object relative to the anchor.
Top Optional Variant. The position (in points) of the upper edge of the new object relative to the anchor.
Width Optional Variant. The width of the ActiveX control, in points.
Height Optional Variant.The height of the ActiveX control, in points.
Anchor Optional Variant. The range to which the ActiveX control is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph in the anchoring range. If this argument is omitted, however, the anchor is placed automatically and the ActiveX control is positioned relative to the top and left edges of the page.
Remarks
ActiveX controls are represented as either Shape objects or InlineShape objects in Microsoft Word. To modify the properties for an ActiveX control, you use the Object property of the OLEFormat object for the specified shape or inline shape.
For information about available ActiveX control class types, see OLE Programmatic Identifiers.
Example
As it applies to the Shape object.
This example adds a check box to the active document.
ActiveDocument.Shapes.AddOLEControl ClassType:="Forms.CheckBox.1"
This example adds a combo box to the active document.
ActiveDocument.Shapes.AddOLEControl ClassType:="Forms.ComboBox.1"
This example adds a check box to the active document, clears the check box, and then adds a caption for it.
Set myCB = ActiveDocument.Shapes _
.AddOLEControl(ClassType:="Forms.CheckBox.1")
With myCB.OLEFormat.Object
.Value = False
.Caption = "Check if over 21"
End With