Over the past three weeks, I've received quite a few emails asking about methods to deal with the "Can't initialize PDFCreator." error message. I've been meaning to write about it for a while, and have been responding to everyone who emailed me about it, but it took me until tonight to write up a page on it. That can be found here, and details an inelegant workaround.
I hate intentionally pausing my code, though. It feels wrong on so many levels, as we're usually trying to speed code up, not slow it down. Because of that, I've spent the last half hour looking for ways to check if the PDFCreator engine is at a point where it can be stopped, and I think I've found it. In my routines here, I ended the routines with the following code:
[vb]'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
pdfjob.cPrinterStop = False
'Wait until the PDF file shows up then release the objects
Do Until Dir(sPDFPath & sPDFName) <> ""
Set pdfjob = Nothing[/vb]
This checks to make sure the job is printed to the printer, tells the printer that's all there is, checks to make sure the PDF file is outputted, then finally unloads the objects.
My rationale for the above was that once the file appears, PDFCreator should be finished. I'm starting to think that's not the case. If we change the Waiting portion to the code below, it seems to be reliably closing PDFCreator on my system. (PDF Creator is NOT closing with the code above)
[vb] 'Wait until the PDF file shows up then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
I'm curious if anyone else can reproduce this. Does the change act reliably to close PDF Creator for you as well? If it does, I see some article updates in the near future. 🙂