Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How does msgbox stop the OnTime event?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How does msgbox stop the OnTime event?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How does msgbox stop the OnTime event?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How does msgbox stop the OnTime event?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How does msgbox stop the OnTime event?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default How does msgbox stop the OnTime event?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default How does msgbox stop the OnTime event?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find %ontime & SUMIF ontime ie: find matching sets within Range... Chris T-M Excel Worksheet Functions 3 October 10th 08 08:14 PM
OnTime bug? Antonio Excel Discussion (Misc queries) 0 June 9th 06 08:24 PM
OnTime VB [email protected] Excel Worksheet Functions 2 May 16th 06 08:43 PM
OnTime Help Mark Scholes Excel Programming 1 January 30th 04 03:48 AM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 08:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"