I still have an issue with Adobe Reader opening as a blank application, and needing to be closed in order for the PDF creation to proceed. It opens and needs to be closed for every file I'm combining; if I am combining 5 files, adobe Reader opens 5 times (and needs to be closed before the next of the 5 documents is processed).
The VBA script I'm using is below (I'm making several Excel sheets into PDF's, then including other PDFs into the PDF I created with the Excel sheets).
If no one can help me with this, can someone just tell me the .coption name to set the "After Autosaving open the document with the default program" to no? This is the only thing I can think of that might be causing this to happen.
Code:
Set pdfjob = New PDFCreator.clsPDFCreator
'Make sure the PDF printer can start
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "Error!"
Exit Sub
End If
'Set defaults
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
'Get Windows' current default printer to set back later
DefaultPrinter = .cDefaultPrinter
.cDefaultPrinter = "PDFCreator"
End With
'Make sheets into PDF's
Application.Sheets("Cover").PrintOut copies:=1, ActivePrinter:="PDFCreator"
Application.Sheets("Report").PrintOut copies:=1, ActivePrinter:="PDFCreator"
Application.Sheets("Raw").PrintOut copies:=1, ActivePrinter:="PDFCreator"
Application.Sheets("Final").PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Include chosen PDF files in new PDF
For i = LBound(PDFList) To UBound(PDFList)
pdfjob.cPrintFile (PDFList(i))
Next i
'Wait until all print jobs have entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 5 + UBound(PDFList) + 1
DoEvents
Loop
'Combine all PDFs into a single file and stop the printer
With pdfjob
.cCombineAll
.cPrinterStop = False
End With
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
'above wait wasn't long enough, pdf not getting created; added 2-second delay
Application.Wait Now + TimeValue("00:00:02")
'reset original Windows' default printer
pdfjob.cDefaultPrinter = DefaultPrinter
pdfjob.cClose
Set pdfjob = Nothing
'Reset aplication's original default printer in case different
Application.ActivePrinter = DefPrntr