Option Explicit
Sub TstPdfCreator()
Dim JobPDF As Object
Dim sNomPDF As String
Dim sCheminPDF As String
sNomPDF = "Essai.pdf"
sCheminPDF = ThisWorkbook.Path & "\"
Set JobPDF = CreateObject("PDFCreator.clsPDFCreator" )
With JobPDF
If .cStart("/NoProcessingAtStartup" ) = False Then
MsgBox "Initialisation de PDFCreator impossible", vbCritical + vbOKOnly, "PDFCreator"
Exit Sub
End If
.cOption("UseAutosave" ) = 1
.cOption("UseAutosaveDirectory" ) = 1
.cOption("AutosaveDirectory" ) = sCheminPDF
.cOption("AutosaveFilename" ) = sNomPDF
' 0=PDF, 1=Png, 2=jpg, 3=bmp, 4=pcx, 5=tif, 6=ps, 7=eps, 8=txt
.cOption("AutosaveFormat" ) = 0
.cClearCache
End With
ActiveWorkbook.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Fichier dans la file d'attente
Do Until JobPDF.cCountOfPrintjobs = 1
DoEvents
Loop
JobPDF.cPrinterStop = False
'Attendre que la file d'attente soit vide
Do Until JobPDF.cCountOfPrintjobs = 0
DoEvents
Loop
JobPDF.cClose
Set JobPDF = Nothing
End Sub
|