'http://www.excelguru.ca/forums/showthread.php?4733-merging-multiple-PDF-files-into-a-single-PDF-file-via-VBA-macro
Sub Test_PDFCreatorCombine()
Dim fn(0 To 1) As String, s As String
fn(0) = "x:\pdf\ken.pdf"
fn(1) = "x:\pdf\ken2.pdf"
s = "x:\pdf\PDFCreatorCombined.pdf"
PDFCreatorCombine fn(), s
If vbYes = MsgBox(s, vbYesNo + vbQuestion, "Open?") Then Shell ("cmd /c " & """" & s & """")
End Sub
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from http://sourceforge.net/projects/pdfcreator/)
' COM interface, http://www.pdfforge.org/pdfcreator/manual/com-interface
' Designed for early bind, set reference to: PDFCreator - Your OpenSource PDF Solution
Sub PDFCreatorCombine(sPDFName() As String, sMergedPDFname As String)
Dim oPDF As PDFCreator.PdfCreatorObj, q As PDFCreator.Queue
Dim pj As PrintJob
Dim v As Variant, i As Integer
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set q = New PDFCreator.Queue
With q
.Initialize
If LBound(sPDFName) = 0 Then
.WaitForJobs UBound(sPDFName) + 1, 1
Else
.WaitForJobs UBound(sPDFName), 1
End If
Set oPDF = New PDFCreator.PdfCreatorObj 'PDFCreator.clsPDFCreator
i = 0
For Each v In sPDFName()
If fso.FileExists(v) Then oPDF.PrintFile v
i = i + 1
Next v
.MergeAllJobs
Set pj = q.NextJob
With pj
.SetProfileByGuid "DefaultGuid"
.SetProfileSetting "Printing.PrinterName", "PDFCreator"
.SetProfileSetting "Printing.SelectPrinter", "SelectedPrinter"
.SetProfileSetting "OpenViewer", "false"
.SetProfileSetting "OpenWithPdfArchitect", "false"
.SetProfileSetting "ShowProgress", "false"
.ConvertTo sMergedPDFname
End With
.ReleaseCom
End With
End Sub