Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub CONVERSION_EN_PDF()
Worksheets("Feuil2").Activate
Dim CREATION_PDF As PDFCreator.clsPDFCreator
Dim Destination As String
Destination = ThisWorkbook.Path
Set CREATION_PDF = New PDFCreator.clsPDFCreator
With CREATION_PDF
'La condition ci-dessous empêche l'ouverture de la boite de dialogue de PDFCreator
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") = Destination
.cOption("AutosaveFilename") = "NOM_FICHIER" & ".pdf"
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Convertit le document en PDF
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Attend que le document soit entré dans la file de Création
Do Until CREATION_PDF.cCountOfPrintjobs = 1
DoEvents
Loop
CREATION_PDF.cPrinterStop = False
'Attend que la Création du document PDF soit terminée
Do Until CREATION_PDF.cCountOfPrintjobs = 0
DoEvents
Loop
CREATION_PDF.cClose
Set CREATION_PDF = Nothing
End Sub