View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
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?