+ Reply to Thread
Results 1 to 5 of 5

Saving backup file on file open

  1. #1
    Forum Contributor
    Join Date
    03-11-2005
    Posts
    115

    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

  2. #2
    Forum Contributor
    Join Date
    03-24-2004
    Location
    Edam Netherlands
    Posts
    181
    You can save your file in the on open event.

  3. #3
    Forum Contributor
    Join Date
    03-11-2005
    Posts
    115
    Thanks, but how ?
    Amy

  4. #4
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote
    in message news:[email protected]...
    >
    > 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
    >




  5. #5
    Forum Contributor
    Join Date
    03-11-2005
    Posts
    115

    additional detail?

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1