Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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
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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


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