I cannot get the timer to stop, when closing my workbook, using the following:
In ThisWorkBook:
Public Sub Workbook_Open()
Call StartTimer
End Sub
Public Sub Workbook_Close()
Call StopTimer
End Sub
In a routine Module:
Option Explicit
Public RunWhen As Date
Public Const cRunWhat = "AutoSave"
Sub StartTimer()
RunWhen = Now + TimeValue("00:00:10")
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=True
End Sub
Sub StopTimer()
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=False
End Sub
Sub AutoSave()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ThisWorkbook.Save
Call StartTimer
Workbooks.Open ActiveWorkbook.FullName 'reopens workbook to show any changes
Application.DisplayAlerts = True
End Sub
Might you advise where the syntax error is ?
I've been researching various Excel VBA forums as well as the internet in general. Everything I've located indicates the above syntax should work - others have posted the same issue and utilize the above coding, apparently with success. So what is going on with my project ?
You assistance is greatly appreciated !
Jim