Using with VBA for Excel 2003

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

That sounds a bit similar to the intermittent error I and others have been seeing. I get it using Autosave, but not from VBA (see my topic on the subject). There seems to be no solution, so I am guessing that the product is simply flaky and suffering the common open source problem of too many fingers in the pie, too little QC. It seems if you need a reliable production solution you need to use a commercial product. Most of the questions like this are not even answered by "team pdfforge", so there appears to be almost no real support for this product. A great shame. May be worth another look in a year or so.

This is what I have done to temporarily allow me to use PDF in my Access app.It is a bit rough but does allow the second DoEvents loop to complete properly without hanging the software.

http://de.pdfforge.org/forum/open-discussion/4200-098-cclose-bug

Hope it helps. Temporarily