B
Bob
I have a rather long macro that, thanks to help I got here, works! I now
need to make some conditional changes. The code is easy to modify, but I
need to present a user form to get some information, including the type of
guide the user wants the macro to produce.
I've got a form (frmMain) with two option controls (typeStudent /
typeLeader) and a Submit command button (cmdSubmit). The form code is:
Dim typeStudent As Boolean
Dim typeLeader As Boolean
Private Sub cmdSelect_Click()
typeLeader = optGuideLeader.Value
typeStudent = optGuideStudent.Value
Me.Hide [also tried Unload Me]
End Sub
In the main macro, I have (for testing purposes):
frmMain.Show
If typeLeader Then Debug.Print "Leader Guide" Else Debug.Print "Student
Guide"
No matter which option I choose on the form, typeLeader in the macro is
always False. Setting a breakpoint before the Show command, I see that
typeLeader is set to True in the form code, but is then False in the macro
code.
I have tried all variations of using or leaving out Dim statements in both
the form and macro code with no difference in function.
According to Steve Roman's book "Writing Word Macros", I can probably move
code from the macro into the form, but there are several things I'd like to
ask on the form, and I'd like to run the form only once at the beginning of
the macro so the rest of the macro can run unattended.
Is there a way to pass a variable from frmMain into the main macro? If so,
any hints? If not, what would be the best alternative?
Thanks!
Bob
need to make some conditional changes. The code is easy to modify, but I
need to present a user form to get some information, including the type of
guide the user wants the macro to produce.
I've got a form (frmMain) with two option controls (typeStudent /
typeLeader) and a Submit command button (cmdSubmit). The form code is:
Dim typeStudent As Boolean
Dim typeLeader As Boolean
Private Sub cmdSelect_Click()
typeLeader = optGuideLeader.Value
typeStudent = optGuideStudent.Value
Me.Hide [also tried Unload Me]
End Sub
In the main macro, I have (for testing purposes):
frmMain.Show
If typeLeader Then Debug.Print "Leader Guide" Else Debug.Print "Student
Guide"
No matter which option I choose on the form, typeLeader in the macro is
always False. Setting a breakpoint before the Show command, I see that
typeLeader is set to True in the form code, but is then False in the macro
code.
I have tried all variations of using or leaving out Dim statements in both
the form and macro code with no difference in function.
According to Steve Roman's book "Writing Word Macros", I can probably move
code from the macro into the form, but there are several things I'd like to
ask on the form, and I'd like to run the form only once at the beginning of
the macro so the rest of the macro can run unattended.
Is there a way to pass a variable from frmMain into the main macro? If so,
any hints? If not, what would be the best alternative?
Thanks!
Bob