AddOLEControl Method

Applies To

InlineShapes collection object, Shapes collection object.

Description

Shapes object: Creates an ActiveX control. Returns the Shape object that represents the new ActiveX control.

InlineShapes object: Creates an ActiveX control. Returns the InlineShape object that represents the new ActiveX control.

Syntax 1

expression.AddOLEControl(ClassType, Left, Top, Width, Height, Anchor)

Syntax 2

expression.AddOLEControl(ClassType, Range)

expression Syntax 1: Required. An expression that returns a Shapes object.

Syntax 2: Required. An expression that returns an InlineShapes object.

ClassType Optional String. The OLE long class name or the programmatic identifier for the ActiveX control to be created.

Left, Top Optional Variant. The position (in points) of the upper-left corner of the new object relative to the anchor.

Width, Height Optional Variant. The width and 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.

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.

Remarks

ActiveX controls are represented as either Shape objects or InlineShape objects in 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.

See Also

AddOLEObject method, AddPicture method, DoVerb method, Object property, OLEFormat object.

Example

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