Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello group,
If a "MsgBox" is open, it prevents "Application.OnTime" from executing the procedure. I want to emulate this behavior. In other words: I'm looking for a way to delay the OnTime event until a button is pushed. Does anybody know how "MsgBox" does this, or how it can me accomplished otherwise? Thanks. Emile van Mierlo |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Look at Help for OnTime. OnTime will fire only if XL is in Ready, Copy,
Cut or Find mode. If another macro is running (i.e., if a sub is displaying a MsgBox), then OnTime will wait until XL is in one of those modes, or until LatestTime, whichever is earlier. In article , "Emile van Mierlo" wrote: Hello group, If a "MsgBox" is open, it prevents "Application.OnTime" from executing the procedure. I want to emulate this behavior. In other words: I'm looking for a way to delay the OnTime event until a button is pushed. Does anybody know how "MsgBox" does this, or how it can me accomplished otherwise? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If a "MsgBox" is open, it prevents "Application.OnTime" from executing
the procedure. I want to emulate this behavior. In other words: I'm looking for a way to delay the OnTime event until a button is pushed. Does anybody know how "MsgBox" does this, or how it can me accomplished otherwise? Look at Help for OnTime. OnTime will fire only if XL is in Ready, Copy, Cut or Find mode. If another macro is running (i.e., if a sub is displaying a MsgBox), then OnTime will wait until XL is in one of those modes, or until LatestTime, whichever is earlier. Ok, but how do I get Excel in a mode that holds OnTime? (How does MsgBox do that) Thanks, Emile |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
MsgBox does that by being displayed by a macro - the running macro takes
XL out of Ready mode. In article , "Emile van Mierlo" wrote: Ok, but how do I get Excel in a mode that holds OnTime? (How does MsgBox do that) |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok, but how do I get Excel in a mode that holds OnTime? (How does MsgBox
do that) MsgBox does that by being displayed by a macro - the running macro takes XL out of Ready mode. If I run a macro which opens a form --similar to a MsgBox-- it will not prevent the OnTime event from executing; so something more happens in a MsgBox. I'm looking for the mechanism that MsgBox uses to change the mode. Just the fact that MsgBox is called from a macro is not it. Thanks. Emile |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It does appear that the fact that the macro has started but not finished
is not enough to stop OnTime firing. If I run test below and leave the userform on the screen, the timer ticks away till it's finished. However, the MsgBox does not appear until I dismiss the userform. Sub test() timed 0 UserForm1.Show vbModal MsgBox "dunnit" End Sub Sub timed(Optional x% = -1) Static counts% If x% < -1 Then counts = x% counts% = counts% + 1 Application.StatusBar = "Counts=" & counts If counts < 10 Then Application.OnTime Now + TimeValue("00:00:01"), "timed" Else Application.StatusBar = "" End If End Sub Emile van Mierlo wrote: Ok, but how do I get Excel in a mode that holds OnTime? (How does MsgBox do that) MsgBox does that by being displayed by a macro - the running macro takes XL out of Ready mode. If I run a macro which opens a form --similar to a MsgBox-- it will not prevent the OnTime event from executing; so something more happens in a MsgBox. I'm looking for the mechanism that MsgBox uses to change the mode. Just the fact that MsgBox is called from a macro is not it. Thanks. Emile |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think you're making an unwarranted assumption that a UserForm is
"similar to a MsgBox", at least in WinXL. There's nothing inherently special about MsgBox - it works just like the Wait method or the InputBox method - it halts the macro until the user presses a button, but doesn't change XL's operating mode. In MacXL, a userform acts exactly like a msgbox - code halts until the userform is dismissed, including OnTime macros. WinXL's userforms, even modal forms, don't act the same way. In article , "Emile van Mierlo" wrote: If I run a macro which opens a form --similar to a MsgBox-- it will not prevent the OnTime event from executing; so something more happens in a MsgBox. I'm looking for the mechanism that MsgBox uses to change the mode. Just the fact that MsgBox is called from a macro is not it. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find %ontime & SUMIF ontime ie: find matching sets within Range... | Excel Worksheet Functions | |||
OnTime bug? | Excel Discussion (Misc queries) | |||
OnTime VB | Excel Worksheet Functions | |||
OnTime Help | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming |