The code below works fine, creates the PDF file but does not close app PDFCreator. The procedure hangs (no error msg) & I have to go into task manager to close app & then of course it is halted on the line "pdfjob.cClose". Anyone got any ideas??? The original code author
Ken Puls at "w w w . excelguru .ca" TIA Lionel downunda!
BTW I am using XL2002 with XP Prof SP3

[vba]
Option Explicit
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub PrintToPDF_Late_Lionels()
'testing May 22
'Modified 22/02/09 for Civic Invoice 09.xls
'Macro Purpose: Print to PDF file using PDFCreator
' Designed for late bind, no references req'd
Dim pdfjob As Object
'Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String

'/// Change the output file name here! ///
Application.ScreenUpdating = False

With ActiveWorkbook
sPDFName = "Civic Invoice " & Range("F5") & ".pdf"
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
End With
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
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
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
'added as an experiment to close PDFCreator
'pdfjob.cPrinterStop = True


Sleep 1000
pdfjob.cClose
'Needed to close PDFCreator

Set pdfjob = Nothing

Application.ScreenUpdating = True
End Sub
[/vba]