Save multiple Excel sheets as PDF
Taylen
-
cs_Le Pivert Posted messages 8437 Status Contributeur -
cs_Le Pivert Posted messages 8437 Status Contributeur -
Hello,
As the title suggests, I'm looking to save multiple sheets from an Excel file as a PDF. My current macro only allows me to save the first sheet and completely ignores the subsequent ones.
However, when saving manually, there is an option to select "Entire Workbook" (File, Save as, PDF, Options (button below the format), Entire workbook) but even the macro recorder does not capture this step, so I do not know how to transcribe it into my code....
If anyone has an idea of the best way to resolve my problem, I thank you in advance.
As the title suggests, I'm looking to save multiple sheets from an Excel file as a PDF. My current macro only allows me to save the first sheet and completely ignores the subsequent ones.
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=newpdf, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
However, when saving manually, there is an option to select "Entire Workbook" (File, Save as, PDF, Options (button below the format), Entire workbook) but even the macro recorder does not capture this step, so I do not know how to transcribe it into my code....
If anyone has an idea of the best way to resolve my problem, I thank you in advance.
5 réponses
Hello,
To save all the tabs with their names:
--
@+ Le Pivert
To save all the tabs with their names:
Option Explicit Dim name, path As String Dim ctr Private Sub CommandButton1_Click() For ctr = 1 To Sheets.Count Sheets(ctr).Select name = Sheets(ctr).Name Save_pdf Next End Sub Private Sub Save_pdf() path = "C:\Users\....\Documents\" 'destination folder path to adjust ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ path & "\" & name & ".pdf", Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ False MsgBox "Save" 'can be removed End Sub
--
@+ Le Pivert