Excel 2013 Print to PDF in VBA

后端 未结 1 1621
独厮守ぢ
独厮守ぢ 2020-12-11 12:59

As it seems that Excel 2013 allow for direct Save as to PDF format, how can in perform this using VBA code ? I would like to build a macro that will automatically create a P

相关标签:
1条回答
  • 2020-12-11 13:53

    Try

    Dim fp As String
    Dim wb As Workbook
    
    fp = "C:\temp\foo.pdf"
    Set wb = ActiveWorkbook
    
    wb.ExportAsFixedFormat Type:=xlTypePDF, _
                           Filename:=fp, _
                           Quality:=xlQualityStandard, _
                           IncludeDocProperties:=True, _
                           IgnorePrintAreas:=False, _
                           OpenAfterPublish:=False
    

    *Note that ExportAFixedFormatmust have all its variables on one line or it will not compile.
    **Note that the '_' characters should allow this to compile whilst not being all on one line

    0 讨论(0)
提交回复
热议问题