VBA Save multiple sheets as a PDF

Опубликовано: 17 Октябрь 2024
на канале: Simplified Excellence
3,369
15

Save multiple sheets as a PDF file.

Code:
Sub save_multiple_sheets_in_pdf()

'save several sheets in one PDF

Dim name_PDF As String
Dim path_PDF As String

'identify PDF file name to create
name_PDF = "MyPDF_version2.pdf"

'create path of the PDF file to create
path_PDF = "C:\Users\brunduk\Documents\Tutorials\" & name_PDF

'select sheets by name
ActiveWorkbook.Sheets(Array("Sheet1", "Sheet4", "Sheet5")).Select

'create the PDF file
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=path_PDF, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False

End Sub

-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.

-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!