TTom
Well-known Member
- Joined
- Jan 19, 2005
- Messages
- 518
For broader discussion that included opening workbook option see:
"Puase macro to allow user to open/activate a WB, continue"
It got a bit long and I wanted to focus one one part, so...
I looking for a simplistic way to pause my macro while the user activates another workbook, once manually activated, the macro continues.
I found some code that might be useful in another forum.
The code allows a mouse click to exit. In my case I might be able to modify to have mouse click goto another part of my proceedure.
(the mouse click would be task of activating another workbook.)
My problem is I do not understand all of the code, I could use clarification on what 'set flag' and 'DoEvents' is and how I might use it.
Any takers on this?
<code>
Private Sub cmdCancel_Click()
Dim m_fCancelIsClicked As Boolean
' set the flag
m_fCancelIsClicked = True
End Sub
Private Sub LongSubRoutine()
Dim m_fCancelIsClicked As Boolean
Do While True
' body of loop
DoSomethingHere
' this line enables the GUI to look for a
' mouse click
DoEvents
' now look for the flag
' and leap out if necessary
If m_fCancelIsClicked Then Exit Do
Loop
End Sub
</Code>
"Puase macro to allow user to open/activate a WB, continue"
It got a bit long and I wanted to focus one one part, so...
I looking for a simplistic way to pause my macro while the user activates another workbook, once manually activated, the macro continues.
I found some code that might be useful in another forum.
The code allows a mouse click to exit. In my case I might be able to modify to have mouse click goto another part of my proceedure.
(the mouse click would be task of activating another workbook.)
My problem is I do not understand all of the code, I could use clarification on what 'set flag' and 'DoEvents' is and how I might use it.
Any takers on this?
<code>
Private Sub cmdCancel_Click()
Dim m_fCancelIsClicked As Boolean
' set the flag
m_fCancelIsClicked = True
End Sub
Private Sub LongSubRoutine()
Dim m_fCancelIsClicked As Boolean
Do While True
' body of loop
DoSomethingHere
' this line enables the GUI to look for a
' mouse click
DoEvents
' now look for the flag
' and leap out if necessary
If m_fCancelIsClicked Then Exit Do
Loop
End Sub
</Code>