首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Adobe Acrobat Pro DC未响应VBA命令

Adobe Acrobat Pro DC未响应VBA命令
EN

Stack Overflow用户
提问于 2020-08-25 20:31:31
回答 1查看 481关注 0票数 0

我目前正在写一个宏,它从excel索引中提取数字。然后查找具有相同名称的PDF文件,并将它们合并为一个PDF文件。

但是我很难让组合文件的部分工作,我不能找出为什么它不应该工作,我有我的引用设置正确。

这就是我遇到麻烦的地方。

代码语言:javascript
复制
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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-25 21:28:13

请添加此行

代码语言:javascript
复制
objCAcroPDDocSource.Open (thisarray(i))

之后

代码语言:javascript
复制
For i = LBound(thisarray) + 1 To UBound(thisarray)

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63578917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档