Export as PDF

Export as PDF file and Auto Save

 Sub ExportAsPDFAutoSave()
    Dim FileName As String    

    ' Auto-generate PDF file name with timestamp
    FileName = ThisWorkbook.Path & "\" & _
                  "Report_" & Format(Now, "yyyymmdd_hhmmss") & ".pdf"    

    ' Export the active sheet directly as PDF (auto-saved)
    ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        FileName:=FileName, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False   

    MsgBox "PDF saved as:" & vbCrLf & newFileName, vbInformation, "Export Complete"

End Sub

एक टिप्पणी भेजें

0 टिप्पणियाँ