Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Error using OnTime Method

I am testing a simple OnTime procedure and receive an error 1004 upon
execution. Entire code is:
Sub SetAlarm()
Application.OnTime TimeValue("10:35:00 am"), "RunTest"
End Sub

Sub RunTest()
Range("A50").End(xlUp).Offset(1, 0).Value = Date
End Sub

Sub SetAnotherAlarm()
Application.OnTime EarliestTime:=TimeValue("10:48:00 am"),
Procedu="RunTest", Schedule:=False
End Sub

The first OnTime procedure runs fine, but when I add the optional
"Schedule", I get an error "Method OnTime of object _Application failed. When
I select Help from the Debugger, I get a blank page. VBA help is installed.

Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Error using OnTime Method

Sam,

To use the Schedule:=False argument to cancel an OnTime
procedure, you must provide OnTime with the *exact* time that the
event was scheduled. See www.cpearson.com/excel/ontime.htm for
details and example code.


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



"Sam" wrote in message
...
I am testing a simple OnTime procedure and receive an error 1004
upon
execution. Entire code is:
Sub SetAlarm()
Application.OnTime TimeValue("10:35:00 am"), "RunTest"
End Sub

Sub RunTest()
Range("A50").End(xlUp).Offset(1, 0).Value = Date
End Sub

Sub SetAnotherAlarm()
Application.OnTime EarliestTime:=TimeValue("10:48:00 am"),
Procedu="RunTest", Schedule:=False
End Sub

The first OnTime procedure runs fine, but when I add the
optional
"Schedule", I get an error "Method OnTime of object
_Application failed. When
I select Help from the Debugger, I get a blank page. VBA help
is installed.

Can anyone help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Error using OnTime Method

Thanks Chip. This was much more helpful than online help.

"Chip Pearson" wrote:

Sam,

To use the Schedule:=False argument to cancel an OnTime
procedure, you must provide OnTime with the *exact* time that the
event was scheduled. See www.cpearson.com/excel/ontime.htm for
details and example code.


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



"Sam" wrote in message
...
I am testing a simple OnTime procedure and receive an error 1004
upon
execution. Entire code is:
Sub SetAlarm()
Application.OnTime TimeValue("10:35:00 am"), "RunTest"
End Sub

Sub RunTest()
Range("A50").End(xlUp).Offset(1, 0).Value = Date
End Sub

Sub SetAnotherAlarm()
Application.OnTime EarliestTime:=TimeValue("10:48:00 am"),
Procedu="RunTest", Schedule:=False
End Sub

The first OnTime procedure runs fine, but when I add the
optional
"Schedule", I get an error "Method OnTime of object
_Application failed. When
I select Help from the Debugger, I get a blank page. VBA help
is installed.

Can anyone help?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Error using OnTime Method

You can't clear (by using Schedule = False) a procedure that hasn't been
scheduled yet.


Here's the Help article:

OnTime Method

Schedules a procedure to be run at a specified time in the future
(either at a specific time of day or after a specific amount of time
has passed).

Syntax

expression.OnTime(EarliestTime, Procedure, LatestTime, Schedule)

expression Required. An expression that returns an Application object.

EarliestTime Required Variant. The time when you want this procedure to be
run.

Procedure Required String. The name of the procedure to be run.

LatestTime Optional Variant. The latest time at which the procedure can be
run. For example, if LatestTime is set to EarliestTime + 30 and Microsoft
Excel is not in Ready, Copy, Cut, or Find mode at EarliestTime because
another procedure is running, Microsoft Excel will wait 30 seconds for the
first procedure to complete. If Microsoft Excel is not in Ready mode within
30 seconds, the procedure won't be run. If this argument is omitted,
Microsoft Excel will wait until the procedure can be run.

Schedule Optional Variant. True to schedule a new OnTime procedure. False
to clear a previously set procedure. The default value is True.

Remarks

Use Now + TimeValue(time) to schedule something to be run when a specific
amount of time (counting from now) has elapsed. Use TimeValue(time) to
schedule something to be run a specific time.



In article ,
Sam wrote:

I am testing a simple OnTime procedure and receive an error 1004 upon
execution. Entire code is:
Sub SetAlarm()
Application.OnTime TimeValue("10:35:00 am"), "RunTest"
End Sub

Sub RunTest()
Range("A50").End(xlUp).Offset(1, 0).Value = Date
End Sub

Sub SetAnotherAlarm()
Application.OnTime EarliestTime:=TimeValue("10:48:00 am"),
Procedu="RunTest", Schedule:=False
End Sub

The first OnTime procedure runs fine, but when I add the optional
"Schedule", I get an error "Method OnTime of object _Application failed. When
I select Help from the Debugger, I get a blank page. VBA help is installed.

Can anyone help?

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
OnTime method xlcharlie Excel Programming 1 February 11th 05 04:20 PM
ontime method? max Excel Programming 8 February 8th 05 09:04 PM
ontime method? max Excel Programming 2 February 7th 05 03:25 PM
ontime Method Bill Krone Excel Programming 1 August 12th 04 04:30 PM
Help me with OnTime Method dolegow Excel Programming 1 October 12th 03 01:52 AM


All times are GMT +1. The time now is 10:01 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"