Hi all
I use this nice chunk of code which works very nicely, essentially this
saves the workbook to 2 locations ( 2 is a backup ), it also stamps ( C2
) with the time it was last saved so you have a visual reference of it.
If you want to trogger some other type of event, simply replace the
SaveBook routine, and or the timer frequency with your desired timeframe
in which to fire.
Put this in the "ThisWorkbook"
Private Sub Workbook_Open()
StartTimer
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub
Then in a Module, use this to start the timer, it is currently set to
trigger ever 30 minutes..
Option Explicit
Public RunTime
Sub StartTimer()
RunTime = Now + #12:30:00 AM#
Application.OnTime RunTime, "SaveBook", schedule:=True
End Sub
Sub SaveBook()
StartTimer
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:= _
"C:\WowSchedMaster.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ChDir "T:\WOW VIC\wow scheduler"
ActiveWorkbook.SaveAs Filename:="T:\WOW VIC\wow
scheduler\WowSchedMaster.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveSheet.Select
Range("C2").Select
Selection.NumberFormat = "hh:mm"
Selection.Value = Now()
End Sub
And finally, this stops the timer...
Sub StopTimer()
On Error Resume Next
Application.OnTime RunTime, "SaveBook", schedule:=False
End Sub
HTH
Mick.