Use standard Acrobat to programmatically merge a PDF?
There are many suggestions on SO and elsewhere for using non-Adobe products to programmatically merge PDFs.
Can't (quite easily) use my paid copy of Adobe Acrobat Standard (not Reader) to programmatically merge two or more PDFs into a new PDF (I know this can be done manually with a combination -> multiple files)?
Would prefer a command (e.g. copy file1.pdf file2.pdf together.pdf) but would be willing to resort to VBA.
Thanks for any ideas!
There is no VBA for Acrobat. VBA is a Microsoft thing (and will apparently disappear soon from what I've read [edit: strike, it looks like it's still alive and well in Office 2010]).
The Acrobat SDK will let you automate Acrobat and do what you want to do, but it's not for the faint of heart. Anyway, it might be easier (short term) to use one of the free solutions you've read elsewhere.
source to share
Sub MergePDFs(nDocs As Integer, BaseFileName As String)
Dim AcroApp As Acrobat.CAcroApp
Dim iDoc As Integer
Dim BaseDocument As Acrobat.CAcroPDDoc
Dim PartDocument As Acrobat.CAcroPDDoc
Dim numPages As Integer
Set AcroApp = CreateObject("AcroExch.App")
Set BaseDocument = CreateObject("AcroExch.PDDoc")
Set PartDocument = CreateObject("AcroExch.PDDoc")
BaseDocument.Open (ActiveWorkbook.Path & "\" & BaseFileName & "_" & 1 & ".pdf")
For iDoc = 2 To nDocs
PartDocument.Open (ActiveWorkbook.Path & "\" & BaseFileName & "_" & iDoc & ".pdf")
numPages = BaseDocument.GetNumPages()
' Insert the pages of Part after the end of Base
If BaseDocument.InsertPages(numPages - 1, PartDocument, 0, PartDocument.GetNumPages(), True) = False Then
MsgBox "Cannot insert pages"
End If
PartDocument.Close
Next iDoc
If BaseDocument.Save(PDSaveFull, ActiveWorkbook.Path & "\" & BaseFileName & ".pdf") = False Then
MsgBox "Cannot save the modified document"
Else
' Remove intermediate documents
For iDoc = 1 To nDocs
Kill ActiveWorkbook.Path & "\" & BaseFileName & "_" & iDoc & ".pdf"
Next iDoc
End If
BaseDocument.Close
AcroApp.Exit
Set AcroApp = Nothing
Set BaseDocument = Nothing
Set PartDocument = Nothing
End Sub
source to share