Using ActiveX Controls on a Document [Excel 2003 VBA Language Reference]

Just as you can add ActiveX controls to custom dialog boxes , you can add controls directly to a document when you want to provide a sophisticated way for the user to interact directly with your macro without the distraction of dialog boxes. Use the following procedure to add ActiveX controls to your document. For more specific information about using ActiveX controls in Microsoft Excel, see Using ActiveX Controls on Sheets .

  1. Add controls to the document

    Display the Control Toolbox, click the control you want to add, and then click the document.

  2. Set control properties

    Right-click a control in design mode and click Properties to display the Properties window.

  3. Initialize the controls

    You can initialize controls in a procedure.

  4. Write event procedures

    All controls have a predefined set of events. For example, a command button has a Click event that occurs when the user clicks the command button. You can write event procedures that run when the events occur.

  5. Use control values while code is running

    Some properties can be set at run time.

See Also | Adding Controls to a Document | Adding Controls to a User Form | Creating a Custom Dialog Box | Creating a User Form | Displaying a Custom Dialog Box | Initializing Control Properties | Setting Control Properties | Using ActiveX Controls on Sheets | Using Control Values While Code Is Running