LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Stopping a timer

I have this code below that runs a timer on a 30 second cycle (1 of 3
timers). My problem is that my code to stop the timer does not work, so if
you close the workbook it restarts on its own. Can any one offer any help
with this? I am able to stop my other 2 timers (in an effort to minimize the
size of this post I did not include the code for the other 2 timers).

Adapted from code found on Chip Pearsons web site.


Public bSELCTIONCHANGE As Boolean
Public Cancel As Boolean
Public Const cRunIntervalSeconds = 30 'Time interval for pulling updated
data from Calendar (in seconds)
Public Const cRunWhat = "TheSub" ' the name of the procedure to run

Private Sub Workbook_Open()
Module2.TheSub
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat, _
Schedule:=False
End Sub


Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat, _
Schedule:=True
End Sub

Sub TheSub()
''''''''''''''''''''''''
' Your code here

Protection.UnProtectAllSheets

On Error GoTo NotKiosk


ThisWorkbook.UpdateLink Name:= _
"\\wtafx\public\Dispatch\Vacation\VacationCale ndar 2010.xlsm",
Type:=xlExcelLinks
GoTo Continue

NotKiosk:
ThisWorkbook.UpdateLink Name:= _
"P:\Dispatch\Vacation\VacationCalendar 2010.xlsm",
Type:=xlExcelLinks

''''''''''''''''''''''''

Continue:

Protection.ProtectAllSheets

StartTimer ' Reschedule the procedure
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat, _
Schedule:=False
End Sub

 
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
Stopping a CountIf Don Kline[_2_] Excel Worksheet Functions 5 May 22nd 09 04:39 PM
stopping code Jase Excel Discussion (Misc queries) 1 October 6th 08 05:42 PM
Stopping A Macro Mike Lewis Excel Programming 4 July 11th 08 01:29 PM
Stopping a formula Roachy Excel Discussion (Misc queries) 3 July 1st 08 03:31 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM


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