• 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

    Hui...

  • 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

Charlie Day

New Member
Hi,

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
 
Charlie Day
You could test something like below:
Code:
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!
 
Back
Top