Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Cancelling Application.OnTime - error message

Hi,
I need to run a process repeatively, but I need to be able to stop it too or
change the timing , but keep getting the following error when trying to stop
the process " Run-Time error '1004': Method 'ONTIME' of Object 'Application'
Failed"

Any idea why, or how I should do it instead.
Many thanks

Sub RunMacro()
Application.OnTime Now + TimeValue("00:00:05"), "OnTimeMacro"

End Sub

Sub OntimeMacro()
MsgBox "hello"
RunMacro

End Sub

Sub byebye()
Application.OnTime EarliestTime:=TimeValue("00:00:05"),
Procedu="my_Procedure", Schedule:=False ' this is where I keep getting
the error?
MsgBox "Bye Bye"
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Cancelling Application.OnTime - error message

What you need to do is save the scheduled time in a public variable, and use
that when stopping it.

Public nTime as Double

Sub RunMacro()
nTime = Now + TimeValue("00:00:05")
Application.OnTime nTime, "OnTimeMacro"

End Sub

Sub OntimeMacro()
MsgBox "hello"
RunMacro

End Sub

Sub byebye()
Application.OnTime EarliestTime:=nTime, Procedu="my_Procedure",
Schedule:=False
MsgBox "Bye Bye"
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dan" wrote in message
...
Hi,
I need to run a process repeatively, but I need to be able to stop it too
or
change the timing , but keep getting the following error when trying to
stop
the process " Run-Time error '1004': Method 'ONTIME' of Object
'Application'
Failed"

Any idea why, or how I should do it instead.
Many thanks

Sub RunMacro()
Application.OnTime Now + TimeValue("00:00:05"), "OnTimeMacro"

End Sub

Sub OntimeMacro()
MsgBox "hello"
RunMacro

End Sub

Sub byebye()
Application.OnTime EarliestTime:=TimeValue("00:00:05"),
Procedu="my_Procedure", Schedule:=False ' this is where I keep getting
the error?
MsgBox "Bye Bye"
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Cancelling Application.OnTime - error message

Thank you very much

"Bob Phillips" wrote:

What you need to do is save the scheduled time in a public variable, and use
that when stopping it.

Public nTime as Double

Sub RunMacro()
nTime = Now + TimeValue("00:00:05")
Application.OnTime nTime, "OnTimeMacro"

End Sub

Sub OntimeMacro()
MsgBox "hello"
RunMacro

End Sub

Sub byebye()
Application.OnTime EarliestTime:=nTime, Procedu="my_Procedure",
Schedule:=False
MsgBox "Bye Bye"
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dan" wrote in message
...
Hi,
I need to run a process repeatively, but I need to be able to stop it too
or
change the timing , but keep getting the following error when trying to
stop
the process " Run-Time error '1004': Method 'ONTIME' of Object
'Application'
Failed"

Any idea why, or how I should do it instead.
Many thanks

Sub RunMacro()
Application.OnTime Now + TimeValue("00:00:05"), "OnTimeMacro"

End Sub

Sub OntimeMacro()
MsgBox "hello"
RunMacro

End Sub

Sub byebye()
Application.OnTime EarliestTime:=TimeValue("00:00:05"),
Procedu="my_Procedure", Schedule:=False ' this is where I keep getting
the error?
MsgBox "Bye Bye"
End Sub




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
Cancelling Application.OnTime Dan Excel Programming 4 July 11th 07 11:22 AM
Windows application error message Tony Tong Excel Discussion (Misc queries) 0 September 15th 06 07:30 AM
Help with Application.OnTime [email protected] Excel Programming 1 April 3rd 06 06:02 PM
Error Message: "xis is not a valid Win32 application" stranchina Excel Discussion (Misc queries) 0 August 21st 05 01:28 PM
Application.OnTIme Mike Excel Programming 8 September 15th 04 03:27 PM


All times are GMT +1. The time now is 10:42 PM.

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"