Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Canceling a Macro that Has Been Scheduled

I have a macro that runs every 15 minutes in a spreadsheet
to update some data. I'm using code similar to the
following to schedule the macro:

1. Application.OnTime Now + TimeValue
("00:00:15"), "my_Procedure"

If I close my spreadsheet, but keep excel open, when the
time has come for the macro to run again, the macro
attempts to run again by opening up the file that I had
closed. What is the best way to stop this?

The help files describe a way to cancel a macro if it has
been scheduled for a specific time:

2. Application.OnTime TimeValue("17:00:00"), "my_Procedure"

3. Application.OnTime EarliestTime:=TimeValue("17:00:00"),
_
Procedu="my_Procedure", Schedule:=False

I haven't been able to figure out how to cancel it if
example 1 was used to schedule the macro. I tried using
variations of #3 in the before_close event for the
workbook. Is there a way to determine which macros are
scheduled to run and what time they have been scheduled to
run?

thanks,

Murray Williams

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Canceling a Macro that Has Been Scheduled

Murray,

To cancel an OnTime macro, you must specify the *exact* time the
macro is scheduled for. Therefore, instead of code like

Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"

You should store the time in a global variable, and use that with
OnTime. E.g.,

Dim RunWhen As Double
Sub StartTimer()
RunWhen = Now + TimeValue("00:00:15")
Application.OnTime RunWhen, "my_Procedure"
End Sub

Then, you can use the RunWhen to cancel the procedu

Application.OnTime RunWhen,,,False

See www.cpearson.com/excel/ontime.htm for more details.


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



"Murray Williams" wrote in message
...
I have a macro that runs every 15 minutes in a spreadsheet
to update some data. I'm using code similar to the
following to schedule the macro:

1. Application.OnTime Now + TimeValue
("00:00:15"), "my_Procedure"

If I close my spreadsheet, but keep excel open, when the
time has come for the macro to run again, the macro
attempts to run again by opening up the file that I had
closed. What is the best way to stop this?

The help files describe a way to cancel a macro if it has
been scheduled for a specific time:

2. Application.OnTime TimeValue("17:00:00"), "my_Procedure"

3. Application.OnTime EarliestTime:=TimeValue("17:00:00"),
_
Procedu="my_Procedure", Schedule:=False

I haven't been able to figure out how to cancel it if
example 1 was used to schedule the macro. I tried using
variations of #3 in the before_close event for the
workbook. Is there a way to determine which macros are
scheduled to run and what time they have been scheduled to
run?

thanks,

Murray Williams



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Canceling a Macro that Has Been Scheduled

Chip,

Thanks a lot ... it works!

Murray
-----Original Message-----
Murray,

To cancel an OnTime macro, you must specify the *exact*

time the
macro is scheduled for. Therefore, instead of code like

Application.OnTime Now + TimeValue

("00:00:15"), "my_Procedure"

You should store the time in a global variable, and use

that with
OnTime. E.g.,

Dim RunWhen As Double
Sub StartTimer()
RunWhen = Now + TimeValue("00:00:15")
Application.OnTime RunWhen, "my_Procedure"
End Sub

Then, you can use the RunWhen to cancel the procedu

Application.OnTime RunWhen,,,False

See www.cpearson.com/excel/ontime.htm for more details.


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



"Murray Williams" wrote in

message
...
I have a macro that runs every 15 minutes in a

spreadsheet
to update some data. I'm using code similar to the
following to schedule the macro:

1. Application.OnTime Now + TimeValue
("00:00:15"), "my_Procedure"

If I close my spreadsheet, but keep excel open, when the
time has come for the macro to run again, the macro
attempts to run again by opening up the file that I had
closed. What is the best way to stop this?

The help files describe a way to cancel a macro if it

has
been scheduled for a specific time:

2. Application.OnTime TimeValue

("17:00:00"), "my_Procedure"

3. Application.OnTime EarliestTime:=TimeValue

("17:00:00"),
_
Procedu="my_Procedure", Schedule:=False

I haven't been able to figure out how to cancel it if
example 1 was used to schedule the macro. I tried using
variations of #3 in the before_close event for the
workbook. Is there a way to determine which macros are
scheduled to run and what time they have been scheduled

to
run?

thanks,

Murray Williams



.

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
canceling simplifying my fractions HI New Users to Excel 1 July 5th 21 12:47 PM
Run Excel macro from Scheduled Task coolthinking Excel Worksheet Functions 4 July 13th 09 03:35 PM
Self canceling checkboxes Glenn Excel Discussion (Misc queries) 3 October 28th 08 03:11 PM
Create macro to copy data on a scheduled basis faureman Excel Discussion (Misc queries) 0 January 25th 07 04:25 PM
canceling auto date update unexceller New Users to Excel 1 June 8th 06 07:40 AM


All times are GMT +1. The time now is 03:59 AM.

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

About Us

"It's about Microsoft Excel"