簡體   English   中英

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

我希望這是足夠的信息。 我真的不想發布整個代碼,因為它很長。 感謝你的付出。

請添加這一行

objCAcroPDDocSource.Open (thisarray(i))

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

你沒有打開Source文件,它沒有什么可以合並的......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM