Microsoft Office Tutorials and References
In Depth Information
Creating a UserForm: An Example
Figure 13-10: The CommandButton1_Click procedure is executed when the button on the
worksheet is clicked.
Testing the dialog box
The next step is to re-activate Excel and try out the procedure that displays the dialog box.
When you click the CommandButton on the worksheet, you’ll find that nothing
happens. Rather, the button is selected. That’s because Excel is still in design mode —
which happens automatically when you insert an ActiveX control. To exit design mode,
click the Developer➜Controls➜Design Mode button. To make any changes to your
CommandButton, you’ll need to put Excel back into design mode.
When you exit design mode, clicking the button will display the UserForm (see Figure 13-11).
When the dialog box is displayed, enter some text into the text box and click OK. Nothing
happens — which is understandable because you haven’t yet created an event-handler procedure for
the OK button.
Click the X (Close) button in the UserForm title bar to dismiss the dialog box.