Acrobat中应参考工作
Here is the guide from Adobe
添加后,您可以使用下面的代码 提示:它可能会导致你纠正编码 - 我不太确定,因为我“盲目”编码它,因为我的电脑中没有Acrobat。逐步调试以查看正在做什么。
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
Acrobat加载项是否提供API?一个对象模型? *通过VBA以编程方式访问的任何内容?如果不是,你可能不得不求助于* SendKeys *,这是一种可怕的,可怕的做事方式。保存为PDF有什么问题? Adobe加载项是做什么的,Excel还没有? –
如果我通常将其另存为PDF,则会压平文档中的所有链接。 –
[This](http://superuser.com/a/921280/165271)可能有帮助 –