Pause macro for user task then continue...

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>
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,144,515
Messages
5,724,811
Members
422,579
Latest member
parsnipsnatcher

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top