Bewerken

Delen via


Shapes.AddFormControl method (Excel)

Creates a Microsoft Excel control. Returns a Shape object that represents the new control.

Syntax

expression.AddFormControl (Type, Left, Top, Width, Height)

expression A variable that represents a Shapes object.

Parameters

Name Required/Optional Data type Description
Type Required XlFormControl The Microsoft Excel control type. You cannot create an edit box on a worksheet.
Left Required Long The initial coordinates of the new object (in points) relative to the upper-left corner of cell A1 on a worksheet or to the upper-left corner of a chart.
Top Required Long The initial coordinates of the new object (in points) relative to the top of row 1 on a worksheet, or to the top of the chart area on a chart.
Width Required Long The initial size of the new object, in points.
Height Required Long The initial size of the new object, in points.

Return value

Shape

Remarks

Use the AddOLEObject method or the Add method of the OLEObjects collection to create an ActiveX control.

Example

This example adds a list box to worksheet one and sets the fill range for the list box.

With Worksheets(1) 
 Set lb = .Shapes.AddFormControl(xlListBox, 100, 10, 100, 100) 
 lb.ControlFormat.ListFillRange = "A1:A10" 
End With

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.