Re: On time kill

Giganews Newsgroups
Subject: Re: On time kill
Posted by:  Chip Pearson (ch…@cpearson.com)
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

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Antonio" <Anton…@discussions.microsoft.com> wrote in message
news:170E613B-F1B9-4BDB-855A-0719CC19C8…@microsoft.com...
>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

Replies

In response to

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