Guest User

chip_pearson_timer

a guest
Mar 8th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Public RunWhen As Double
  4. Public Const cRunIntervalSeconds = 10 ' two minutes
  5. Public Const cRunWhat = "TheSub" ' the name of the procedure to run
  6.  
  7. Sub StartTimer()
  8. RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
  9. Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
  10. Schedule:=True
  11. End Sub
  12.  
  13. Sub TheSub()
  14. ''''''''''''''''''''''''
  15. ' Your code here
  16. MsgBox "hi"
  17. ''''''''''''''''''''''''
  18. StartTimer ' Reschedule the procedure
  19. End Sub
  20. Sub StopTimer()
  21. On Error Resume Next
  22. Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
  23. Schedule:=False
  24. End Sub
Advertisement
Add Comment
Please, Sign In to add comment