18/05/2023
How to save workbook as a PDF using VBA.
Sub SaveWorkbookAsPDF()
Dim FilePath As String
Dim FileName As String
' Set the file path and name for the PDF file
FilePath = "C:\Your\Desired\Path\" ' Specify the desired file path
FileName = "YourFileName.pdf" ' Specify the desired file name
' Save the workbook as a PDF file
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=FilePath & FileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False
' Display a message when the PDF file is saved
MsgBox "Workbook saved as PDF file: " & FilePath & FileName, vbInformation
End Sub