Adobe Acrobat Pro DC 没有响应 VBA 命令

Adobe Acrobat Pro DC is not responding to VBA commands

我目前正在编写一个宏,它采用 excel 索引中的数字。然后找到同名的PDF文件合并成1个PDF文件。

但是我无法让组合文件的部分工作,而且我无法找出为什么它不能工作我已经正确设置了我的引用。

这是我遇到问题的部分。

Dim objCAcroPDDocDestination As Acrobat.CAcroPDDoc
Dim objCAcroPDDocSource As Acrobat.CAcroPDDoc
Dim i As Integer
Dim iFailed As Integer
Dim strSaveAs As String
Dim MergePDFs As Boolean


strSaveAs = GetNewFolder & "\" & TxtNewFileName.Text
 
On Error GoTo NoAcrobat:
'Initialize the Acrobat objects
Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc")
Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc")
 
'Open Destination, all other documents will be added to this and saved with
'a New Filename
objCAcroPDDocDestination.Open (thisarray(LBound(thisarray))) 'open the first file
 
'Open each subsequent PDF that you want to add to the original
  'Open the source document that will be added to the destination
    For i = LBound(thisarray) + 1 To UBound(thisarray)
        
       If objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then
          MergePDFs = True
        Else
          'failed to merge one of the PDFs
          iFailed = iFailed + 1
        End If
        objCAcroPDDocSource.Close
    Next i
objCAcroPDDocDestination.Save 1, strSaveAs 'Save it as a new name
objCAcroPDDocDestination.Close
Set objCAcroPDDocSource = Nothing
Set objCAcroPDDocDestination = Nothing
 
NoAcrobat:
If iFailed <> 0 Then
    MergePDFs = False
End If
On Error GoTo 0

我希望这些信息足够了。我真的不想 post 整个代码,因为它很长。 谢谢你的努力。

请添加这一行

objCAcroPDDocSource.Open (thisarray(i))

之后

For i = LBound(thisarray) + 1 To UBound(thisarray)

您没有打开 Source 文件,没有要合并的内容...