+ Reply to Thread
Results 1 to 8 of 8

Save as PDF with file name set to date and time it was saved

  1. #1
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Save as PDF with file name set to date and time it was saved

    Good Afternoon all

    I have the following code that will save my active sheet as a PDF and name that file Test but what i really want is to save the file as the date and time it was saved. I need it to save sheet8 really not the Active sheet as i cant guarantee sheet8 will be active.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Save as PDF with file name set to date and time it was saved

    OillyBob55,

    One easy way to do this would be by using the "Text" and "Now" functions.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Save as PDF with file name set to date and time it was saved

    If the codename for the sheet is Sheet8,

    Please Login or Register  to view this content.
    If the name is Sheet8, change Sheet8 to Worksheets("Sheet8")
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Save as PDF with file name set to date and time it was saved

    @DarkF1ame: You can't have a colon in a filename.

  5. #5
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Save as PDF with file name set to date and time it was saved

    @shg

    Good to know. Whoops. Your solution was infinitely more elegant anyway.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Save as PDF with file name set to date and time it was saved

    FYI the extension .pdf is automatically added when exporting so it's not necessary to add it when composing the filename.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Save as PDF with file name set to date and time it was saved

    Thanks Shg works perfectly.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Save as PDF with file name set to date and time it was saved

    You're welcome.

+ 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. Save File with Date and Time Stamp
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-26-2019, 12:46 AM
  2. User, Time and Date stamp when file is saved on shared drive
    By DrewRE in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2012, 11:34 AM
  3. Replies: 0
    Last Post: 04-16-2012, 10:57 AM
  4. save file as date and time
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2011, 05:47 AM
  5. [SOLVED] Excel should have a function for last date and time file was saved
    By fwbuckley in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-18-2006, 09:05 AM
  6. Macro to save Excel file with date and time in the file name?
    By sonic_d_hog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2006, 02:00 PM
  7. Save file with time date stamp
    By oberon.black in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2005, 09:05 PM
  8. [SOLVED] 'document not saved' for 'save' or 'save as' an EXCEL file
    By Judy Chuang in forum Excel General
    Replies: 1
    Last Post: 07-11-2005, 06:05 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