Adding the Command Buttons

Ready to add two CommandButtons — OK and Cancel — to the dialog box? Follow along:

1. Make sure the toolbox is displayed. If it isn't, choose ViewOToolbox.

2. If the Properties window isn't visible, press F4 to display it.

3. In the toolbox, drag a CommandButton into the dialog box to create a button.

As you see in the Properties box, the button has a default name and caption: CommandButton1.

4. Make sure the CommandButton is selected. Then activate the Properties window and change the following properties:

Property Change To

Name OKButton

Caption OK

Default True

5. Add a second CommandButton object to the UserForm and change the following properties:

Property Change To

Name CancelButton

Caption Cancel

Cancel True

6. Adjust the size and position of the controls so your dialog box looks something like Figure 16-5.

Figure 16-5:

The UserForm with two Command-Button controls.

Figure 16-5:

The UserForm with two Command-Button controls.

0 0

Post a comment