Hmm... I see...
So the issue is that the code I gave you tries to create a new instance of PDFCreator, instead of binding to an existing instance which is where your files are.
All things being equal, this SHOULD work:
Code:
Sub CombinePDFs()
'Author : Ken Puls
'Macro Purpose: Print to PDF file using PDFCreator
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
'/// Change the output file name here! ///
sPDFName = "Test.pdf"
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
Set pdfjob = GetObject(, "PDFCreator.clsPDFCreator")
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
End With
'Combine all jobs already in the PDFCreator queue
pdfjob.cCombineAll = True
pdfjob.cPrinterStop = False
'Wait until the file shows up before closing PDF Creator
Do
DoEvents
Loop Until Dir(sPDFPath & sPDFName) = sPDFName
pdfjob.cClose
Set pdfjob = Nothing
End Sub
But it won't. It's gagging on the line to connect to the PDF Creator class. And I'm not sure why.
The irony here is that, if you gave me a list of the files (with paths) that you want to merge into one PDF in a column, I could make that happen quite easily. But trying to attach to where you've already got the files printed is a bit of a monster. In fact, I could even build a "picker" to allow you to collect the file paths of all files you'd want to collect, then print them, so long as they were MS Office documents.
Frustrating!
Bookmarks