How to prevent macro being run when another one is running
Posted: Thu May 06, 2004 10:40 am
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
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