PC Review


Reply
Thread Tools Rate Thread

Cancelling Application.OnTime - error message

 
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      11th Jul 2007
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"),
Procedure:="my_Procedure", Schedule:=False ' this is where I keep getting
the error?
MsgBox "Bye Bye"
End Sub

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      11th Jul 2007
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, Procedure:="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" <(E-Mail Removed)> wrote in message
news3285EC8-B727-4B28-9ED1-(E-Mail Removed)...
> 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"),
> Procedure:="my_Procedure", Schedule:=False ' this is where I keep getting
> the error?
> MsgBox "Bye Bye"
> End Sub
>



 
Reply With Quote
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      11th Jul 2007
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, Procedure:="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" <(E-Mail Removed)> wrote in message
> news3285EC8-B727-4B28-9ED1-(E-Mail Removed)...
> > 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"),
> > Procedure:="my_Procedure", Schedule:=False ' this is where I keep getting
> > the error?
> > MsgBox "Bye Bye"
> > End Sub
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
application.ontime cbs Microsoft Excel Programming 1 11th Mar 2009 07:23 AM
Using application.ontime J.W. Aldridge Microsoft Excel Programming 1 26th Oct 2007 10:38 PM
Cancelling Application.OnTime =?Utf-8?B?RGFu?= Microsoft Excel Programming 4 11th Jul 2007 11:22 AM
Application.OnTIme Mike Microsoft Excel Programming 8 15th Sep 2004 03:27 PM
application.ontime Svein Olav Steinmo Microsoft Excel Misc 0 29th Aug 2003 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.