I've created some code that I can pass a word.document object to, and it then converts the word document to a PDF file. The code sometimes works and sometimes does not? If I pass 50 word.document objects to it in a loop, I will get 30 converted docuemnts but 20 that nothing occurs with? I'm at a loss as to what is causing this. Hope someone can help me. Here's the vba code I'm using.
Public PDFCreator1 As PDFCreator.clsPDFCreator
Private ReadyState As Boolean, DefaultPrinter As String Public Sub CreatePDFFile(Doc As Word.Document)
Set PDFCreator1 = New clsPDFCreator
If PDFCreator1.cStart("/NoProcessingAtStartup") = False Then MsgBox "Process Failed" End If
It looks like no one was able to help me with a solution, but I was able to find one on my own. I believe that my above code was shuttinh down the PDFCreator before it actually had a chance to generate the PDF copy. I'm not sure why since I was monitoring the countofprintjobs property, but once I changed my code to look at both the number of prints, and monitor the output folder for a produced file, then shut down PDF Creator, everything started working after that.
Here is the code revision that worked for me.
Public Sub CreatePDFFile(Doc As Object) Dim brestart As Boolean Set PDFCreator1 = New clsPDFCreator
Do brestart = False Set PDFCreator1 = New PDFCreator.clsPDFCreator If PDFCreator1.cStart = False Then 'PDF Creator is already running. Kill the existing process Shell "taskkill /f /im PDFCreator.exe", vbHide DoEvents Set PDFCreator1 = Nothing brestart = True End If Loop Until brestart = False