ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving backup file on file open (https://www.excelbanter.com/excel-programming/349692-saving-backup-file-file-open.html)

AmyTaylor[_32_]

Saving backup file on file open
 

Hi everyone, and a happy new year.
I want to include some code in a spreadsheet, whereby when a
spreadsheet is opened it automatically creates and saves a backup with
the days date in the file name ?

Is it also possible to include whereby when the file is saved it saves
itself with the days date, and if there is more than one save per day
it saves a number on the file path ? eg: SavedFileBackup200601051.xls

Hope that either or both of these options are doable.
Thanks in advance
Amy xx


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=498631


Kaak[_55_]

Saving backup file on file open
 

You can save your file in the on open event.


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=498631


AmyTaylor[_33_]

Saving backup file on file open
 

Thanks, but how ?
Amy


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=498631


Norman Jones

Saving backup file on file open
 
Hi Amy,

Try:

'==============
Private Sub Workbook_Open()
Dim sStr As String

sStr = Format(Now, "yyyymmdd hh-mm")

Me.SaveAs Filename:=Me.Name & " " & sStr, _
FileFormat:=xlWorkbookNormal
End Sub
'<<==============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module):

'==============
Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
'<<==============

This will not add a sequential number to multiple daily backups, but it adds
the backup time. Hopefully, this will satisfy your requirements.


---
Regards,
Norman



"AmyTaylor" wrote
in message ...

Hi everyone, and a happy new year.
I want to include some code in a spreadsheet, whereby when a
spreadsheet is opened it automatically creates and saves a backup with
the days date in the file name ?

Is it also possible to include whereby when the file is saved it saves
itself with the days date, and if there is more than one save per day
it saves a number on the file path ? eg: SavedFileBackup200601051.xls

Hope that either or both of these options are doable.
Thanks in advance
Amy xx


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile:
http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=498631




AmyTaylor[_34_]

Saving backup file on file open
 

Thank you very much Norman, sorry for not getting back to you until
now.
Can you let me know, is it possible to change the code so that:

a) the file is only saved when the file is opened as read-write and not
read-only

and
b) can the backup copy be saved to a directory in the same file path
called \backup ?

Thanks for your help
Amy xx


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=498631



All times are GMT +1. The time now is 09:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com