auto save a backup copy of a workbook

E

Ese

auto save a backup copy of a workbook with the original Sheet.
I am using Excel 2003 version
 
B

Bob Phillips

In the ThisWorkbook code module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime nTime, "SaveFile", , False
End Sub

Private Sub Workbook_Open()
Call SaveFile
End Sub

In a standard code module

Public nTime As Double

Public Sub SaveFile()
Dim PosExt As Long
With ThisWorkbook

nTime = Now + TimeSerial(1, 0, 0) 'every hour
PosExt = InStrRev(".", .Name)
.SaveCopyAs .Path & Application.PathSeparator & Left(.Name, PosExt -
1) & Format(Now, "yyyy-mm-dd hh-mm-ss")
Application.OnTime nTime, "SaveFile"
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top