+ Reply to Thread
Results 1 to 3 of 3

Save over file with new name but delete the old one

  1. #1
    Registered User
    Join Date
    10-17-2014
    Location
    Wausau, WI
    MS-Off Ver
    2014
    Posts
    17

    Save over file with new name but delete the old one

    I am looking for help creating a commandbutton that, when clicked, saves the current file with a new name. I already have this part done but I have to go back into the file folder and delete the old version of the file. I am hoping it is possible to do this while it saves the new version of the file.
    Please Login or Register  to view this content.
    Cell P46 is a cell that groups other cells together to get a specific name. After a person selects a checkbox it adds 1 of a possible 3 different suffixes onto the filename and saves it. The way it is set up now I will end up with 4 files in the same folder that are just the same thing only updated. I want it to delete all older versions of the file whenever it updates.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,758

    Re: Save over file with new name but delete the old one

    This code is more complex than necessary to do what you describe. It isn't necessary to change all those Application attributes to be able to save a file; the action won't trigger alerts, screen updating, calculation, or events. Also I don't see why you show the user a dialog box to save the file when you already know what name you want to use. That will allow the user to save it with any name, in any folder. If that's what you intend to do, you can use your original line of code for that.

    I would suggest the following, which I have tested:

    Please Login or Register  to view this content.
    I just gave this a second thought--do you have a BeforeSave or AfterSave event handler? In that case you may want to turn off events, but it all depends on what the handler does and whether you want to disable it for this particular save.
    Last edited by 6StringJazzer; 02-03-2015 at 01:26 PM. Reason: Added blue text
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-17-2014
    Location
    Wausau, WI
    MS-Off Ver
    2014
    Posts
    17

    Re: Save over file with new name but delete the old one

    This code works perfectly and I think most of my coding has redundant lines in it. I am new to this stuff and I think I should probably start asking for more help. Thank you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Use Dir in If statement to delete old file, save new file
    By qwerty7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2015, 12:07 PM
  2. [SOLVED] Need help to save file to new folder and delete old file using same file name
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2012, 11:16 PM
  3. Perform a delete on file save
    By KevinThomas in forum Excel General
    Replies: 7
    Last Post: 03-01-2010, 10:50 AM
  4. VBA to save CSV file as XLS, delete CSV
    By yuryyuryyury in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2007, 09:32 AM
  5. Save file, create .pdf, (Now delete .xls file)
    By daniels012 in forum Excel General
    Replies: 4
    Last Post: 03-30-2007, 05:14 PM

Tags for this Thread

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