Hi,
I am struggling to prevent the application.ontime to stop running when I am either not on that workbook or have already closed that workbook.
This is my code:
Public RunWhen As Double
Public Const RunWhat = "RunEveryTwoMinutes"
Sub RunEveryTwoMinutes()
Call gp_daybook
Call missing
RunWhen = Now + TimeValue("00:00:15")
Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, procedure:=RunWhat, schedule:=False
End Sub
Probably pretty ropey code, but best I can do as I am not the best at it. Do I need to have code that runs when I close the workbook or something?
Bookmarks