I have some VBA macros set up as toolbar buttons. When one of the macros is running, however, its possible to press another toolbar button. That causes the running macro to stop running, and starts the other one. That is a problem... I want to prevent macros from running until the running one has done its thing.
Is there an easy/clean way to do it? The two ways I thought of are to 1) set IntelliCAD.Visible to False when starting a macro and True when ending it, 2) use IntelliCAD.RunCommand to undefine the vbarun, -vbarun commands at the beginning of the macros (and redefine them when done). The first one isn't an option to me, and the second one could pose problems if the macro stops before redefining.
Has anyone run across this problem? Any other solutions? I was using the code below to test it.
Public Sub test()
Dim i As Integer, dStart As Double
For i = 1 To 1000
dStart = Timer
Do While Timer < dStart + 0.1 ' wait 0.1 seconds
DoEvents
Loop
Debug.Print i
Next i
End Sub
Thanks...
Kenn
#3
Thanks for the response. It looks like running a second macro immediately stops the first one, so setting a global flag in VBA or using a reading/writing a registry setting with VBA wouldn't work. When the second macro read the flag to see if it was ok to proceed, the first macro would already have been stopped. The global flag/registry setting would have to be checked by the code for the toolbar button. I think that setting one of the USER* variables to a certain value would be the easiest way. I may just stick with undefining/redefining the vbarun, -vbarun commands. It basically serves the same purpose and prevents someone from using the Tools > VB > Macros option.
Re: How to prevent macro being run when another one is running
#4Prevent multiple macros from running simultaneously to avoid interrupting the active macro's execution. Consider using a flag or lock to disable other macro buttons while a macro rice purity test is running.
Re: How to prevent macro being run when another one is running
#5use a flag variable or check if the macro is already running. Set the flag at the start and clear it upon completion.annakena33 wrote: ↑Wed Jun 12, 2024 9:36 pmPrevent multiple macros from running simultaneously to avoid interrupting the active macro's execution. Consider using a flag or lock to disable other macro buttons while a macrosex dolls cheap is running.