+ Reply to Thread
Results 1 to 23 of 23

save file with current date

  1. #1
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    save file with current date

    hi, I am trying to do something simple in excel 2013 vba but it's not working. I just want to save a version of the active workbook in the existing subdirectory but with a date stamp at the end of the file name. I am using the code below. appreciate any help.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: save file with current date

    Try...Untested.
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: save file with current date

    I had to replace your quotation marks and then this worked:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    I got a 1004 error.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: save file with current date

    I tested my code - did you try my code?

  6. #6
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    yes, xladept. I go the 1004 on both replies. It says

    Method 'SaveAs' of object'_workbook' failed

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: save file with current date

    I used this and it worked.

    Please Login or Register  to view this content.
    Note you may have revise your code

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    thanks john. it is very close; however the filename is just the date. I'd like to keep the original filename and append the date to it.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: save file with current date

    Did you retype those quotation marks?

  10. #10
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    @ xladept I just copied the line of code you sent as is

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: save file with current date

    Maybe:

    Please Login or Register  to view this content.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: save file with current date

    It happens this way sometimes, at least it's a rare occurrence - maybe next time

  13. #13
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    @ john davis it kind of worked once but when I went to do it again it gives me a 1004 error again and my current active workbook is renamed to sheetname29_Jun-17

  14. #14
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: save file with current date

    This should work....
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    thanks sintek. I think it does work but I got a warning about the file extension when I tried to open it again. as far as I can tell it's the same file content so nothing seems to be missing, but will keep checking.

  16. #16
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: save file with current date

    Add this
    Please Login or Register  to view this content.
    ]
    after
    Please Login or Register  to view this content.

  17. #17
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: save file with current date

    Quote Originally Posted by xi603 View Post
    @ john davis it kind of worked once but when I went to do it again it gives me a 1004 error again and my current active workbook is renamed to sheetname29_Jun-17
    It worked when I tested it. I'd have to see the actual code you are using. There is nothing in the code which would change the name of the workbook and there would be a space between the workbook name and the current date.

  18. #18
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    thanks sintek. you last msg is not showing up here, although I saw it in email. it does work now, but am curious why the file icon does not look like the other macro files or even the regular xlsx files.

  19. #19
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    I see the other messages now.

  20. #20
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    hi sintek, the macro works fine but I think it is saving the file in an older version hence the different icon and my saved file is much bigger than the excel 2013 version I am using. is there a way to save it in excel 2013 format?

  21. #21
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    i looked on the internet and changed the file format to 52 and it seems to work although the icon still looks a little different. thx for everyone's help!

  22. #22
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: save file with current date

    Are you wanting to save the workbook as a normal xlsx file....
    Please Login or Register  to view this content.

  23. #23
    Forum Contributor
    Join Date
    03-31-2017
    Location
    usa
    MS-Off Ver
    2013
    Posts
    104

    Re: save file with current date

    @sintek I figured it out. I just had to save it as an xlsm file. thanks for all your help.

+ 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] VB to save to file of current date
    By sroot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2015, 07:16 AM
  2. [SOLVED] Save file as current date
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-28-2014, 03:54 PM
  3. Save File as Current Date/Time
    By wxman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2007, 08:30 AM
  4. Save File with Current Date Info
    By dianahatesboys in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-31-2007, 03:15 PM
  5. save a file with current date inserted automatically
    By Budster in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2006, 12:00 AM
  6. [SOLVED] Save File with the current date and time.
    By sd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2005, 08:35 AM
  7. Save excel file as current date
    By webbey21 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2005, 11:06 PM

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