我能够运行下面的代码,我有Acrobat Reader软件安装2017年以及使用Adobe Acrobat XI Pro和蒸馏器XI。
我有没有XI Pro或Distiller中的另一台计算机。
第一个问题,当我打开我的Excel工作表中我得到
隐藏模块中的编译错误:XXXXX
第二个问题是在引用我有
MISSING:使用Adobe Acrobat 10.0类型库
我取消它,然后再次运行,然后我得到Set acroDoc = New AcroPDDoc
错误
我注意到,我在我的工作Excel中的“ACROBAT”功能区,在我不工作的Excel的我不知道。
Dim acroExchangeApp As Object
Set app = CreateObject("Acroexch.app")
Dim filePaths As Collection 'Paths for PDFS to append
Set filePaths = New Collection
Dim fileRows As Collection 'Row numbers PDFs to append
Set fileRows = New Collection
Dim sourceDoc As Object
Dim primaryDoc As Object ' PrimaryDoc is what we append too
Dim insertPoint As Long ' PDFs will be appended after this page in the primary Doc
Dim startPage As Long ' First desired page of appended PDF
Dim endPage As Long ' Last desired page of appended PDF
Dim colIndex As Long '
Dim numPages As Long
Dim acroDoc As Object
Set acroDoc = New AcroPDDoc
Set primaryDoc = CreateObject("AcroExch.PDDoc")
OK = primaryDoc.Open(filePaths(1))
Debug.Print "PRIMARY DOC OPENED & PDDOC SET: " & OK
For colIndex = 2 To filePaths.count
query_start_time = time()
start_memory = GetWorkingMemoryUsage
numPages = primaryDoc.GetNumPages() - 1
Set sourceDoc = CreateObject("AcroExch.PDDoc")
OK = sourceDoc.Open(filePaths(colIndex))
Debug.Print "(" & colIndex & ") SOURCE DOC OPENED & PDDOC SET: " & OK
numberOfPagesToInsert = sourceDoc.GetNumPages
'inserts pages
acroDoc.Open source_file_name
insertPoint = acroDoc.GetNumPages - 1
If endPage > 1 Then
OK = primaryDoc.InsertPages(insertPoint, sourceDoc, startPage, endPage - startPage, False)
Debug.Print "(" & colIndex & ") " & endPage - startPage & " PAGES INSERTED SUCCESSFULLY: " & OK
Else
OK = primaryDoc.InsertPages(insertPoint, sourceDoc, startPage, endPage - startPage + 1, False)
Debug.Print "(" & colIndex & ") " & endPage - startPage + 1 & " PAGES INSERTED SUCCESSFULLY: " & OK
End If
Set sourceDoc = Nothing
Next colIndex
OK = primaryDoc.Save(PDSaveFull, filePaths(1))
Debug.Print "PRIMARYDOC SAVED PROPERLY: " & OK
Set primaryDoc = Nothing
app.Exit
Set app = Nothing
最新的变化:
首先,我得到
编译错误,不能找到项目或库
于是我取消选中“MISSING:使用Adobe Acrobat 10.0类型库”,它溶解这个错误,
现在收到以下错误,我做了这个更改后:
Set acroDoc = New AcroPDDoc
到Set acroDoc = CreateObject("AcroExch.PDDoc")
现在在新的生产线得到一个错误,像这样,
您目前混合后期绑定的早期绑定。为了使计算机之间的代码的可移植性,总是使用后期绑定。这使计算机能够找到在运行时库而不是硬链接到一个文件中手动每台电脑上运行代码之前。
更改此设置:
Set acroDoc = New AcroPDDoc
为此:
Set acroDoc = CreateObject("AcroExch.PDDoc")
这样说的:http://www.needforexcel.com/single-post/2015/10/09/Difference-Between-Early-Binding-Late-Binding