Is there a way to interrupt "Ontime" macro once it is started?

C

Carl

I have a macro that saves the workbook 30 minutes after opening using
"OnTime". Is there a way to stop this once it has started? I know one way is
to close and reopen the workbook and Excel but is there a way to do it
without having to close the workbook? Thanks in advance.
 
J

Jim Thomlinson

Nope... the best you will do is to pop a mesage for the user warning them of
the save...

if msgbox("Do you wanna save???", vbyesno) = vbyes then thisworkbook.save
 
P

Peter T

If you mean abort a scheduled Ontime before it's occurred, store the
'EarliestTime' and set the optional Schedule to false, eg

Sub myOnTime(bRun As Boolean)
Static tme As Date ' or at module level
If bRun Then
tme = Now + TimeSerial(0, 0, 5) ' 5 sec's from now
End If
Application.OnTime tme, "myMacro", schedule:=bRun

End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top