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)可能有幫助 –