+ Reply to Thread
Results 1 to 9 of 9

Code for saving a back-up file

  1. #1
    Registered User
    Join Date
    08-02-2007
    Posts
    30

    Code for saving a back-up file

    Hi,

    I would like to add a button in to an excel sheet which will save a back-up file automatically when it is clicked.

    The catalogue where the file shall be saved can be chosen by the user and the name of the file should automatically be provided (set by the code) and including a date/time stamp in to the file name if possible.

    COuld someone help?


    Thx


    Marcus

  2. #2
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    How about this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-02-2007
    Posts
    30

    Back-Up file

    Thx a lot!

    This helps perfectly well.


    Regards,


    Marcus

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    If you are using a version of Excel later than 97 you could replace

    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Registered User
    Join Date
    08-02-2007
    Posts
    30

    Saving back-up file without closing current file

    Thx for code examples. Works well.

    However, when saving the file as back-up, the "old file" is automatically closed and I now continue to work in the back-up file. This is not what I want. I want the back-up file to be saved in the "background" only and the continue to work in the original file.

    Is this possible?


    Regards,


    Marcus

  6. #6
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Using the code below, when the backup file is saved, the original file is resaved. Will this work for your needs?
    Note: This assumes cell A1 is available to use as a helper cell. Change as your needs dictate.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-02-2007
    Posts
    30

    Code for saving back-up file

    Thx Ikaabod,

    I will test it. I think it works well for my application.

    Some questions:
    1) Is it really required to use a "helper cell"? Why is it not possible to get the path and filename without using a helper cell?

    2). Using the standard "save as" application works well in order to search and define the correct location for the file but for the user it is somewhat "strange" as he/she should just ignore the "filename" (as this is given by the code). Is there a way to just get up a dialogue box which letīs the user pick the folder where to save a backup file but "save as filename" would be left out? Also, clicking "cancel" on the "save as" dialogue box still results in saving a back-up file (this is maybe not regarded as "Good Practice").

    Thx again!


    Marcus

  8. #8
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    I use the helper cell in order to get information about the current file's location... there's probably another way to do it, but I don't know off the top of my head.

    The last code I sent should be set up to abort the save if the user hits cancel.

    Try looking at this link for selecting a folder... if you need help implementing it let me know. (Sorry I didn't see this link earlier).

  9. #9
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    This saves only the backup file... not the original. Call the macro highlighted blue to run code. Change the red text to suit your needs.
    Please Login or Register  to view this content.
    Note: Most of this code comes from the link I provided previously.

+ 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