VBA Save sheet as PDF

Опубликовано: 04 Март 2026
на канале: Simplified Excellence
731
6

Save a sheet to a PDF file.

Code:
Sub save_sheet_in_pdf()

'save a worksheet as a PDF file

Dim ws_sheet As Worksheet
Dim name_PDF As String
Dim path_PDF As String

'Identify name of the PDF file to create
name_PDF = "My PDF.pdf"

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

'identify sheet to save as PDF
Set ws_sheet = Worksheets("Sheet5")

'select sheet
ws_sheet.Select

'create PDF
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!