Each report will have to be saved as independent pdf then they can be merged. Need VBA reference to Adobe Acrobat 8.0 Type Library.
Code from my project to merge pdfs
Code:
Sub BatchMergePDF()
Dim fso As Object, SourceFolder As Object, SFolder As Object, SSFolder As Object, SSSFolder As Object, PDFile As Object
'Relies on the Adobe Acrobat 6.0 Type Library
Dim objCAcroPDDocDestination As Acrobat.AcroPDDoc
Dim objCAcroPDDocSource As Acrobat.AcroPDDoc
Dim i As Integer, booMerge As Boolean
'Initialize the objects
Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc")
Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc")
Set fso = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = fso.GetFolder("R:\Projects\LabReportsOLD\")
For Each SFolder In SourceFolder.subfolders
For Each SSFolder In SFolder.subfolders
If SSFolder.Name <> "Soils & Aggregate" Then
i = 1
For Each PDFile In SSFolder.Files
If i = 1 Then
objCAcroPDDocDestination.Open SSFolder.Path & "\" & PDFile.Name
End If
If i > 1 Then
objCAcroPDDocSource.Open SSFolder.Path & "\" & PDFile.Name
objCAcroPDDocDestination.InsertPages objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0
objCAcroPDDocSource.Close
End If
i = i + 1
Next
objCAcroPDDocDestination.Save 1, SFolder.Path & "\" & SSFolder.Name & ".pdf"
objCAcroPDDocDestination.Close
Else
For Each SSSFolder In SSFolder.subfolders
i = 1
For Each PDFile In SSSFolder.Files
If i = 1 Then
objCAcroPDDocDestination.Open SSSFolder.Path & "\" & PDFile.Name
End If
If i > 1 Then
objCAcroPDDocSource.Open SSSFolder.Path & "\" & PDFile.Name
objCAcroPDDocDestination.InsertPages objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0
objCAcroPDDocSource.Close
End If
i = i + 1
Next
objCAcroPDDocDestination.Save 1, SFolder.Path & "\Soils & Aggregate " & SSSFolder.Name & ".pdf"
objCAcroPDDocDestination.Close
Next
End If
Next
Next
Debug.Print SFolder.Name
Set PDFile = Nothing
Set SFolder = Nothing
Set SSFolder = Nothing
Set SSSFolder = Nothing
Set SourceFolder = Nothing
Set fso = Nothing
Set objCAcroPDDocSource = Nothing
Set objCAcroPDDocDestination = Nothing
End Sub