This is a common problem. There were a few suggestions in the old forums, which had varying results for different people. I posted a solution that I thought would work in all situations - unfortunately, I didn't get a chance to see if anyone commented on my solution before the forums were lost.
I don't remember exactly what I found as the "magic bullet" that fixed the problem.
I added a few DoEvents and some wait timers ... I think specifically it was the placement of a DoEvent (VB6) that seemed to resolve the issue.
Sorry I can't be more help. I had a pretty good write up about this problem before the Forums got fragged.
Here is my code for Word 2003 VBA COM:
Private WithEvents PDFCreator1 As PDFCreator.clsPDFCreator
Private FileSaved As Boolean, ReadyState As Boolean, DefaultPrinter As String, LoopCount As Long
Public Sub SaveWholeDocumentAsPDF(Filename As String)
FileSaved = False
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Please save the document first!", vbExclamation
Exit Sub
End If
Set PDFCreator1 = New clsPDFCreator
With PDFCreator1
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator."
Exit Sub
End If
DefaultPrinter = ActivePrinter
SetPrinter "PDFCreator"
End With
With PDFCreator1
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = ActiveDocument.Path
.cOption("AutosaveFilename") = Filename
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cOption("Papersize") = "Letter"
.cClearCache
DoEvents
ActiveDocument.PrintOut Background:=False
DoEvents
.cPrinterStop = False
End With
SetPrinter DefaultPrinter
LoopCount = 0
Do Until FileSaved = True
If LoopCount >= 100 Then 'End loop after approx 25 seconds
MsgBox "Loop has run for more than 25 seconds - Cannot close PDFCreator"
PDFCreator1.cPrinterStop = True
PDFCreator1.cClearCache
Exit Do
End If
DoEvents
Sleep 250
LoopCount = LoopCount + 1
Loop
DoEvents 'Just to be ABSOLUTELY sure that PDFCreator is ready to close!
Sleep 250 'Wait another 1/4 of a second
PDFCreator1.cClose
Set PDFCreator1 = Nothing
Sleep 250
DoEvents
End Sub
Private Sub PDFCreator1_eError()
MsgBox "ERROR [" & PDFCreator1.cErrorDetail("Number") & "]: " & PDFCreator1.cErrorDetail("Description")
End Sub
Private Sub PDFCreator1_eReady()
'File was saved
FileSaved = True
PDFCreator1.cPrinterStop = True
End Sub
Private Sub SetPrinter(Printername As String)
With Dialogs(wdDialogFilePrintSetup)
.Printer = Printername
' .Printer.PaperSize = wdPaperLetter
.DoNotSetAsSysDefault = True
.Execute
End With
End Sub