Re: On time kill

Giganews Newsgroups
Subject: Re: On time kill
Posted by:  Chip Pearson (ch…
Date: Wed, 7 Jun 2006

To cancel an OnTime event, you must provide the EXACT time that
it is scheduled to run. Therefore, you should store that value in
a public variable, and pass that variable to OnTime. E.g.,

Public RunWhen As Double
Sub StartOnTime()
    RunWhen = Now + TimeValue("00:01:00")
    Application.OnTime RunWhen, "max_min"
End Sub

Sub EndOnTime()
    Application.OnTime RunWhen, , , False
End Sub

Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC

"Antonio" <Anton…> wrote in message
>I have the following code that runs every minute
> Application.OnTime Now + TimeValue("00:01:00"), "max_min"
> I want to cancel that OnTime schedule in the Before_Close
> event.
> How can I do that. I am having difficulties with the
> EarliestTime
> Application.OnTime EarliestTime:=Now+TimeValue("00:01:00"),
> Procedure:="max_min", Schedule:=False
> does not work
> If I don't kill the call to max_min the spreadsheet keeps
> opening up or
> causing errors when it is opened.
> Thanks,
> Antonio


In response to

On time kill posted by Antonio on Wed, 7 Jun 2006