It's easy to run a macro when a user clicks buttons in a dialog. Create the macro, then right click on the button and select Assign Macro. In the case of the wizard the same Cancel, Back, Next, and Finish buttons appear in each dialog. There are four common routines to set a global variable (GWizReturn) to a different value for each button. The main routine then uses GWizReturn to control processing in the Select Case statements. Here's a partial listing of the code:
GProgress = 0
Wiz1Entry:
Call WizStep1 'WizStep1 will set GWizReturn depending on what button
' the user clicks.
'Set the tracking variable to indicate first dialog is complete.
GProgress = 1
Select Case GWizReturn
Case GO_BACK, CANCEL
Call UndoWiz1
GoTo TheVeryEnd
Case GO_NEXT
'now set up for the second step of the wizard.
Wiz2Entry:
Call WizStep2(UserInput:=True)
GProgress = 2
Select Case GWizReturn
Case GO_BACK
Call UndoWiz2
GoTo Wiz1Entry
Case CANCEL
Call UndoWiz2
Call UndoWiz1
GoTo TheVeryEnd
Case GO_NEXT
Wiz3Entry:
Call WizStep3(UserInput:=True)
' . . .
' Code for steps 3 through 5 deleted for clarity
' . . .
End Select
Case FINISH
Call FinishIt
End Select
Case FINISH
Call FinishIt
End Select
Example 6. Main routine processing