on-internet
← Community

Save worksheet as PDF on Mac

Stack Overflow ·

I am working on a macro to save the active sheet as a PDF file with a special name. The macro I created runs but saves every sheet in several PDF and puts the name of the sheet at the end of the file name. Sub PrintPDF() Dim wksSheet As Worksheet Dim strFile As String Set wksSheet = ActiveSheet 'strFile = Format(Now(), "yyyymm") _ & ".pdf" strFile = "blabla" _ & "_" _ & Format(Now(), "yyyymm") _ & "_" _ & "name2" _ & " " _ & Replace(Replace(wksSheet.Cells(1, 2).Value, " ", ""), ".", "_") _ & ".pdf" strFile = ThisWorkbook.Path & ":" & strFile wksSheet.SaveAs Filename:=strFile, FileFormat:=xlPDF

Comments

Sign in or sign up to comment and upvote.

No comments yet.