You should have adobe Pro installed.
This is a merge pdf function... ArrayFilePaths should contain paths (C:/.../file.pdf) to which PDF's should be merged.
Sub MergePdfs(arrayFilePaths)
Logger.Info("MergePDFs")
Try
AdobeApp = CreateObject("Acroexch.app")
primaryDoc = CreateObject("AcroExch.PDDoc")
Catch
MessageBox.Show("Adobe Pro required. Canceling PDF Merge", "MergePdfs")
Logger.Info("Adobe Pro required. Canceling PDF Merge")
Exit Sub
End Try
' Copy primary doc and open the copy.
' arrayFilePaths(0)' copy this file and open the copy?
oOriginalName = arrayFilePaths(0)
oCopyName = Left(arrayFilePaths(0), Len(arrayFilePaths(0)) -4) & "-PACKET.pdf"
System.IO.File.Copy(oOriginalName, oCopyName)
arrayFilePaths(0) = oCopyName
OK = primaryDoc.Open(arrayFilePaths(0))
' Logger.Info("PRIMARY DOC OPENED & PDDOC SET: " & OK)
For arrayIndex = 1 To UBound(arrayFilePaths)
numPages = primaryDoc.GetNumPages() -1
sourceDoc = CreateObject("AcroExch.PDDoc")
OK = sourceDoc.Open(arrayFilePaths(arrayIndex))
' Logger.Info("SOURCE DOC OPENED & PDDOC SET: " & OK)
numberOfPagesToInsert = sourceDoc.GetNumPages
OK = primaryDoc.InsertPages(numPages, sourceDoc, 0, numberOfPagesToInsert, False)
' Logger.Info("PAGES INSERTED SUCCESSFULLY: " & OK)
OK = primaryDoc.Save(PDSaveFull, arrayFilePaths(0))
' Logger.Info("PRIMARYDOC SAVED PROPERLY: " & OK)
sourceDoc = Nothing
Next arrayIndex
primaryDoc = Nothing
AdobeApp.Exit
AdobeApp = Nothing
End Sub
Hope it helps.
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________