Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run - time error '1004'
Hello,
I have a file with a code for blinking text. At this moment I am entering some data in this file, so I click on macro in the tool bar to stop the blink texts. The problem is that after I save the file and come to close the file, a window appears with this error. Run - time error '1004' Method 'On Time' of object '_Application' failed. Continue End Debug Help When I click Debug, it is giving me these offending lines: Application.OnTime RunWhen, "StartBlink1", , False Application.OnTime RunWhen, "StartBlink2", , False Application.OnTime RunWhen, "StartBlink3", , False Application.OnTime RunWhen, "StartBlink4", , False Any help please, Thanks in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run - time error '1004'
Hi Max,
I would suggest that you have started the timer a number of times and have not been stopping it properly. Timer must be stopped with same variable that started it otherwise xl does not know which "session" of the timer to stop. The following is an extract of an example from a timer that displays the time in a text box. It has a button to start the timer and a button to stop it. You must stop Application.OnTime with exactly the same variable that you started it with. Best to declare it as a Public varible in the declarations area at the top of a standard module. Public nextCheck As Date 'The following code re-runs the sub at intervals set by nextCheck variable Sub RunAtIntervals() Calculate 'Force calculation to update time 'Include code here to copy elapsed time 'to Userform TextBoxes if required. 'Set nextCheck to number of seconds 'required before next re-calculate. nextCheck = Now + TimeSerial(0, 0, 1) 'Following line programs this sub to 'execute at the nextCheck time interval. Application.OnTime nextCheck, _ Procedu="RunAtIntervals" End Sub 'The following sub stops the Ontime with a button click. 'Note it stops the timer started with NextCheck not 'one started with any other variable. Sub StopTimer() 'Cancel OnTime. 'Returns error if previously stopped hense the On Error Resume Next. On Error Resume Next Application.OnTime _ EarliestTime:= nextCheck, _ Procedu=" RunAtIntervals", _ Schedule:=False If Err.Number 0 Then Exit Sub On Error GoTo 0 End Sub -- Regards, OssieMac |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Application Run Time Error 1004 and Stack Error | Excel Programming |