使用VBA如何调用Adobe创buildPDFfunction

Sheets("Key Indicators").ExportAsFixedFormat Type:=xlTypePDF, Filename:=ArchivePath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=False 

目前这是我所拥有的。

我知道如何ExportAsFixedFormat PDF,但我需要知道如何做是使用VBA访问Acrobat下的创buildPDFfunction(如下图所示)。 如果我做ExportAsFixedFormat链接被夷为平地。 Acrobat“创buildPDF”将允许我将Excel转换为包含超链接的PDF。

AdobePDFMakerForOffice

我该怎么做?

我正在使用Excel 2016和Adobe Pro DC

在这里输入图像描述 这些是我的Adobe参考

Acrobat Reference应该可以工作
这是Adobe的指南
一旦添加,你可以使用下面的代码提示:它可能会导致你正确的编码 – 我不太确定,因为我“盲目”编码,因为我没有在我的PC中的Acrobat。 一步一步debugging,看看有什么做。

 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 

以下页面可能会提供更好的帮助: Link1 , Link2

 Sub PDF() ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "C:\Users\PCNAME\Documents\Book1.pdf", Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ True End Sub 

请尝试上面的代码

 With ActiveSheet .ExportAsFixedFormat Type:=xlTypePDF, Filename:="N:\JKDJKDJ", _ Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False End With 

您可以使用ExportAsFixedFormat作为PDF发布任何Excel范围。 没有必要设置一个参考Acrobat。

 ' Usage: ' PublishRangePDF(Thisworkbook, fileName) : Will Publish the entire Workbook ' PublishRangePDF(AvtiveSheet, fileName) : Will Publish all selected worksheets ' PublishRangePDF(Range("A1:H100"), fileName) : Will Publish Range("A1:H100") Sub PublishRangePDF(RangeObject As Object, fileName As String, Optional OpenAfterPublish As Boolean = False) On Error Resume Next RangeObject.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=OpenAfterPublish On Error GoTo 0 End Sub