VBA Save as PDF

Excel VBA Save as PDF with path

Excel

Excel VBA Save as VBA at Required path. Following is the code to save pdf

Thisworkbook.Select
Worksheets("Sheet1").Select
Range("A2:F15").Select

'Define variable for Path - path = "D:\System files\Documents" & "\"
    ChDir "D:\System files\Documents"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "D:\System files\Documents\Book12.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        True


'--- Another Example of Code ----

Sub PDF_SaveAs()
Dim i As Long 
Dim StrPath As String
Dim StrFlNm As String
Path = ActiveWorkbook.Path & "\"
For i = 1 To 3
  With Sheets("Report01" & i)
    fileName = "Report01" & i & Format(.Range("H7"), " mmmm yyyy")
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & fileName, _
      Quality:=xlQualityStandard, IncludeDocProperties:=True, _
      IgnorePrintAreas:=False, OpenAfterPublish:=True
  End With
Next
End Sub

Before this check Option in Save As menu – File type = PDF.

Enjoy!!!

Leave a Reply

Your email address will not be published. Required fields are marked *