Hello!
I want to send specific worksheets in Excel to PDF and save in a specified folder. I have done this successfully using:
However, I'd like to take It one step further by adding today's date when it saves into the file name. So the above would become "Stats 11-03-2016.pdf".Code:Sub SendPDF() ' SendToPDF Macro Sheets(Array("COVER", "In DAILY Summary", "Out DAILY Summary", _ "Out DAILY by Time")).Select Sheets("COVER").Activate ChDir "C:\MyFileLocation" ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "C:/MyOutputLocation\Stats.pdf", Quality:= _ xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=False End Sub
I found this in an inferior forum for adding the date part. I've tried using part of the below in the above but doesn't work. Any ideas please?
Thanks!Code:Sub Save() Dim dtDate As Date dtDate = Date Dim strFile As String strFile = "X:\file" & Format(dtDate, "mm-dd-yyyy") & ".xlsm" ActiveWorkbook.SaveAs Filename:=strFile, FileFormat _ :=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False End Sub




Reply With Quote
