Using Command Buttons in a User Form

Figure 14-1 shows an example of a UserForm that uses CommandButton controls as a simple menu. Setting up this sort of thing is very easy, and the code behind the UserForm is very straightforward. Each CommandButton has its own event handler procedure. For example, the following procedure is executed when CommandButton1 is clicked:

Private Sub CommandButton1_Click() Call Macro1 Unload Me End Sub

Button Menu Demo

! Execute Macro 1 ;

Execute Macro 4

Execute Macro 2

Execute Macro 5

Execute Macro 3

Execute Macro 6

Cancel

Figure 14-1: This dialog box uses CommandButtons as a menu.

Figure 14-1: This dialog box uses CommandButtons as a menu.

This procedure simply calls Macro1 and closes the UserForm. The other buttons have similar event handler procedures.

0 0

Post a comment