I'm referencing pdfCreator from some VBA code in Excel. I need to cycle through about 300 records and create a separate Word document for each one, and then create a pdf for each of the Word documents.The overall code is very long, but the part that refers to pdfCreator is:
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
sPDFName = lname & FName & DateAndTimeVal
sPDFPath = "c:\\!\\"
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Print the document to PDF
oWDDoc.PrintOut
'ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Sleep 5000
Set pdfjob = Nothing
This code is in a loop that cycles through each of the Excel rows. The code works fine but after several iterations (its always a different number, ranging from about 10 to 35 or so) something hangs and I get a message from Excel saying Excel is waiting for an OLE process to finish and it won't go any farther. If I get rid of the pdfCreator code the rest of the program works fine. Also, it always hangs after a different number of iterations, so the problem seems to be with the pdfCreator program.
Has anyone run into this or have a suggestion on how to handle it?
Thanks- Eric