Microsoft Office Tutorials and References
In Depth Information
Chapter 14: UserForm Examples
Figure 14-1: This dialog box uses CommandButtons as a menu.
Private Sub CommandButton1_Click()
Call Macro1
Unload Me
End Sub
This procedure hides the UserForm, calls Macro1 , and then closes the UserForm. The other
buttons have similar event-handler procedures.
Using a ListBox in a UserForm
Figure 14-2 shows another example that uses a ListBox as a menu. Before the UserForm is
displayed, its Initialize event-handler procedure is called. This procedure, which follows, uses
the AddItem method to add six items to the ListBox:
Figure 14-2: This dialog box uses a ListBox as a menu.
Private Sub UserForm_Initialize()
With ListBox1
.AddItem “Macro1”
.AddItem “Macro2”
.AddItem “Macro3”
.AddItem “Macro4”
.AddItem “Macro5”
.AddItem “Macro6”
End With
End Sub
Search JabSto ::

Custom Search