1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA for Saving Excel PDF file with Timestamp

Discussion in 'VBA Macros' started by Charlie Day, Nov 13, 2017.

  1. Charlie Day

    Charlie Day New Member


    I have a Excel file that I need to save frequently in PDF format (I use clear sheet vba every time to overwrite information every week) with different revisions. This task would be greatly facilitated if a VBA macro would save the file - to a pre-defined network location - and append current Date and Time stamp to its original filename. All I'm doing is selecting the workbook area, converting it to pdf and giving it a location which is working fine except its overwriting the pdf file every time I execute the Macro. I want a program in which the file name is saved with the time stamp so that each time when I run the save pdf macro it saves a new file.
    following is the snippet of code I'm using currently:

    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = "$C$1:$V$21"
    Sheets("Weekly Dashboard").Select
    ActiveSheet.ExportAsFixedFormat xlTypePDF, "N:\Folder1\Folder2\Folder3\Weekly Items\Dashboard.pdf", , , False
    End Sub

    Thanks in advance
    Version: Excel 2007
  2. vletm

    vletm Excel Ninja

    Charlie Day
    You could test something like below:
    Code (vb):

    with Sheets("Weekly Dashboard")
        .PageSetup.PrintArea = "$C$1:$V$21"
        .ExportAsFixedFormat xlTypePDF, "N:\Folder1\Folder2\Folder3\Weekly Items\" & format(now,"yyyymmdd hhmmss") & "Dashboard.pdf", , , False
    end with
    Yes, I didn't test this!
    sathishsusa and Charlie Day like this.
  3. Charlie Day

    Charlie Day New Member

    Worked, Thanks so much

Share This Page