I am able to create a pdf file from a Word document using COM objects (in VB within Microsoft Access).
I now want to combine the resultant pdf file with a number of other existing pdf files into a single pdf file.
Below is the code I use to convert a Word doc to a pdf. How do I modify or extend this to carry out the combination. The object model would suggest that I use .cCombineAll but am not clear how it knows which files to combine.
Any help would be appreciated.The code is:
Public Function producePDF(sourceDocument, destinationFolder, destinationFilename) As Boolean
' to create a pdf form of the quote, saved in the same directory
On Error GoTo errorCode
DoCmd.Hourglass True
producePDF = True ' assume everything will be OK
Dim thePDFCreator As PDFCreator.clsPDFCreator
Set thePDFCreator = New clsPDFCreator
With thePDFCreator
.cStart "/NoProcessingAtStartup"
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = destinationFolder
.cOption("AutosaveFilename") = destinationFilename
.cOption("AutosaveFormat") = 0 ' 0 = PDF
Dim theDefaultPrinter As String
theDefaultPrinter = .cDefaultPrinter ' note the default printer
.cDefaultPrinter = "PDFCreator"
.cClearCache
.cPrintFile sourceDocument
.cPrinterStop = False
End With
Dim aStep
aStep = 0 ' wait for the output file to be created
Do While (thePDFCreator.cOutputFilename = "") And (aStep < (maxTime * 1000 / sleepTime))
aStep = aStep + 1
Sleep 200
Loop
Dim theOutputFilename As String
theOutputFilename = thePDFCreator.cOutputFilename ' remember it for later
With thePDFCreator
.cDefaultPrinter = theDefaultPrinter ' re-establish the default printer
Sleep 200
.cClose
End With
Sleep 2000 ' Wait until PDFCreator is removed from memory
If theOutputFilename = "" Then
producePDF = False
End If
exitCode:
DoCmd.Hourglass False
Exit Function
errorCode:
producePDF = False
MsgBox Err.Description, , "Error (producePDF) " & Err.Number
Resume exitCode
End Function