Microsoft Office Tutorials and References
In Depth Information
Part 5: Manipulating Excel Objects
Creating Advanced User Forms
Any time the Va flue property of the MultiPage control is changed, the control’s Change event
is fired. The MultiPage1_Change event found in the user form module is the real heart of the
wizard’s control. Each possible page value is tested and the code appropriate for that page is
Private Sub MultiPage1_Change()
If MultiPage1.Value = 0 Then
CommandButton2.Enabled = False
CommandButton3.Enabled = True
UserForm1.Caption = "Wizard App - Step 1 of 3"
ElseIf MultiPage1.Value = 1 Then
CommandButton2.Enabled = True
CommandButton3.Enabled = True
UserForm1.Caption = "Wizard App - Step 2 of 3"
ElseIf MultiPage1.Value = 2 Then
CommandButton2.Enabled = True
CommandButton3.Enabled = False
UserForm1.Caption = "Wizard App - Step 3 of 3"
MsgBox "Error: invalid page value"
End If
End Sub
For the first page ( Va flue = 0 ), the Prev button is disabled, the Next button is enabled, and the
user form’s Caption property is updated to reflect that this is the first step of the wizard. The
Prev button is disabled because it’s impossible to move before the first step in the wizard. If
the user wants to end the wizard, the Cancel button can be pressed.
On the second page ( Va flue = 1 ), both the Prev and Next buttons are enabled because the user
can choose to press either button. The user form’s Caption property is also updated.
On the last page ( Va flue = 2 ), the Next button is disabled because there are no other steps in
the wizard. Unlike the other steps in this wizard, there’s an extra line of code that prepares the
information on the form before the form is displayed to the user. A call to GenerateOptions
handles the necessary work.
If the Va flue property doesn’t match any of the pages associated with the steps of the wizard,
a message box displays an error message. In theory, you should never see this message. In
practice, it can be very useful when debugging the navigation logic.
Search JabSto ::

Custom Search