Greetings:
We've been leveraging the code below for several years to automate the production and assembly of a collection of PDFs, and all has gone well as we've upgraded from Acrobat 10 Pro to 11 Pro to DC Pro. However, as my staff has upgraded recently to Acrobat Pro 2020 and Office 365 we've encountered an issue.
The creation of individual PDFs still occurs without fail, but the code now breaks at the point noted below when it begins to assemble the "packet" of multiple PDFs.
Code snippet here:
Code
- Sub FinalizePacket(DocsToAssemble As Variant, pktFileName As String)
- Dim docDest As Acrobat.CAcroPDDoc
- Dim docSource As Acrobat.CAcroPDDoc
- Dim i As Long
- Set docDest = CreateObject("AcroExch.PDDoc")
- Set docSource = CreateObject("AcroExch.PDDoc")
- 'Open first file, all other files get added to it
- docDest.Open (DocsToAssemble(0))
- 'loop through DocsToAssemble, open file, merge with destination and close file
- For i = 1 To UBound(DocsToAssemble)
- docSource.Open (DocsToAssemble(i))
- If docDest.InsertPages(docDest.GetNumPages - 1, docSource, 0, docSource.GetNumPages, 0) = False Then
- MsgBox "Could not insert file: " & DocsToAssemble(i)
- Exit Sub
- End If
- docSource.Close
- Next i
- PDFSave docDest, pktFileName
- docDest.Close
- Set docSource = Nothing
- Set docDest = Nothing
- End Sub
We cannot figure out why the upgrade to Acrobat Pro 2020 would cause the code to fail. Anyone have any thoughts?
Much appreciated.