Adobe Acrobat Pro DC未响应VBA命令



我目前正在编写一个宏,它将数字作为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

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

请添加此行

objCAcroPDDocSource.Open (thisarray(i))

之后

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

您没有打开Source文件,它不需要合并。。。

最新更新