Using VBA how do I call up the Adobe Create PDF function

前端 未结 4 1615
误落风尘
误落风尘 2020-12-09 00:33
  Sheets(\"Key Indicators\").ExportAsFixedFormat Type:=xlTypePDF,
 Filename:=ArchivePath, Quality:=xlQualityStandard,
 IncludeDocProperties:=True, IgnorePrintAreas _         


        
4条回答
  •  执念已碎
    2020-12-09 01:19

    Acrobat Reference should work
    Here is the guide from Adobe
    Once added, you may use the following code Tip: It may lead you to correct coding -I'm not quite sure since I coded it "blindly" because I don't have Acrobat in my PC-. Debug step by step to see what's doing.

    Sub ExportWithAcrobat()
    Dim AcroApp As Acrobat.CAcroApp 'I'm not quite sure it's needed since we are creating the doc directly
    Dim AcrobatDoc As Acrobat.CAcroPDDoc
    Dim numPages As Long
    Dim WorkSheetToPDF As Worksheet
    Const SaveFilePath = "C:\temp\MergedFile.pdf"
        Set AcroApp = CreateObject("AcroExch.App") 'I'm not quite sure it's needed since we are creating the doc directly
        Set AcrobatDoc = CreateObject("AcroExch.PDDoc")
        'it's going to be 0 at first since we just created
        numPages = AcrobatDoc.GetNumPages
        For Each WorkSheetToPDF In ActiveWorkbook.Worksheets
        If AcrobatDoc.InsertPages(numPages - 1, WorkSheetToPDF, 0, AcrobatDoc.GetNumPages(), True) = False Then 'you should be available to work with the code to see how to insert the sheets that you want in the created object ' 1. If Part1Document.InsertPages(numPages - 1, "ExcelSheet?", 0, AcrobatDoc.GetNumPages(), True) = False
        MsgBox "Cannot insert pages" & numPages
        Else ' 1. If Part1Document.InsertPages(numPages - 1, "ExcelSheet?", 0, AcrobatDoc.GetNumPages(), True) = False
        numPages = numPages + 1
        End If ' 1. If Part1Document.InsertPages(numPages - 1, "ExcelSheet?", 0, AcrobatDoc.GetNumPages(), True) = False
        Next WorkSheetToPDF
        If AcrobatDoc.Save(PDSaveFull, SaveFilePath) = False Then ' 2. If Part1Document.Save(PDSaveFull, "C:\temp\MergedFile.pdf") = False
        MsgBox "Cannot save the modified document"
        End If ' 2. If Part1Document.Save(PDSaveFull, "C:\temp\MergedFile.pdf") = False
    End Sub
    

    Following pages may provide better assistance: Link1, Link2

提交回复
热议问题