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
Sheets("Feuil2" ).PrintOut copies:=1, ActivePrinter:="PDFCreator"
Do Until JobPDF.cCountOfPrintjobs = 1
DoEvents
Loop
JobPDF.cPrinterStop = False
Do Until JobPDF.cCountOfPrintjobs = 0
DoEvents
Loop
JobPDF.cClose
Set JobPDF = Nothing
End Sub |