Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Create PDF from Excel


Generate/Create PDF file from the workbook with the specified range/settings.

Public Sub PDF()

    With ActiveSheet.PageSetup

        .CenterHeader = "Sample Excel File Saved As PDF"

        .Orientation = xlLandscape

        .PrintArea = "$A$1:$AY$100"

        '.PrintArea = ActiveSheet.UsedRange

        .PrintTitleRows = ActiveSheet.Rows(5).Address

        .Zoom = False

        .FitToPagesTall = False

        .FitToPagesWide = 1

    End With

 

    ActiveSheet.ExportAsFixedFormat _

    Type:=xlTypePDF, _

    Filename:="Sample Excel File Saved As PDF 2", _

    Quality:=xlQualityStandard, _

    IncludeDocProperties:=False, _

    IgnorePrintAreas:=False, _

    from:=1, _

    To:=5, _

    OpenAfterPublish:=True

End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us