AutoSave
Hi Memphis,
It look simple to me.
1:
Put this code in a module.
' -- start of code
Public RunWhen As Double
Public Const cRunIntervalSeconds = 2 ' two minutes
Public Const cRunWhat = "TheSub" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat, _
Schedule:=True
End Sub
Sub TheSub()
MSG = MsgBox("Hello World", vbOKCancel)
If MSG = vbOK Then
ActiveWorkbook.Save
StartTimer ' Reschedule the procedure
End If
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat, _
Schedule:=False
End Sub
' --- end of code
2: for the commandbutoon:
Private Sub cmdBegin_Click()
StartTimer
End Sub
|