Sub ImprPdf()
 Dim pdfjob As Object, myprint As String, Port As Integer, Q As String, NoMFichier As String, fichname As String
 Dim Destin As String, txt As String, NomPdf As String, DefaultPrinter As String
 Q = ""
 For Port = 0 To 9 ' test tous les ports imprimantes pour activer pdfCreator en imprimante active
         
        myprint = "PDFCreator sur Ne0" & Port & ":"
         On Error Resume Next
         ActivePrinter = myprint
         If ActivePrinter = myprint Then
             
            Exit For
         End If
     Next
  Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
     With pdfjob
         If .cstart("/NoProcessingAtStartup") = False Then ' démarre Pdf Creator en cas de probleme il te le dit
             MsgBox " PDFCreator n'a pu être démarrer.", vbCritical + vbOKOnly, "PrtPDFCreator"
             Exit Sub
         End If
     End With
 
    NoMFichier = "Récapitulatif Ibis Tarbes " & mois & " " & année ' détermine le non de ton fichier
     fichname = ThisWorkbook.Path & "\" & NoMFichier & ".pdf" ' tu choisis où tu veux que ton fichier soit enregistrer
     Destin = fichname
     txt = Dir(Destin, vbNormal) ' test te permettant de savoir si un fichier du m^me nom existe déja
     If txt <> "" Then
         MsgBox "Ce récapitulatif existe déja"
         Exit Sub
     End If
     
       
             
            NomPdf = NoMFichier & ".pdf"
             
            
                With pdfjob ' application de la configuration demandé plus haut ( nom et chemin du fichier)
                     .cOption("UseAutosave") = 1
                     .cOption("UseAutisaveDirectory") = 1
                     .cOption("AutosaveDirectory") = (ThisWorkbook.Path)
                     .cOption("AutosaveFilename") = NomPdf
                     .cOption("AutosaveFormat") = 0
                     .cClearCache
                     DefaultPrinter = .cDefaultprinter
                 End With
             
           
             ThisWorkbook.Worksheets("feuil1").PrintOut Copies:=1, ActivePrinter:=Q & myprint & Q
            
             
                Do Until pdfjob.cCountOfPrintjobs = 1
                     DoEvents
                 Loop
                 pdfjob.cPrinterStop = False
                 Do Until pdfjob.cCountOfPrintjobs = 0
                     DoEvents
                 Loop
                 'Call Sleep(750)
                 With pdfjob
                     .cDefaultprinter = DefaultPrinter
                     .cClearCache
                 End With
                 Set pdfjob = Nothing
                 MsgBox ("Le nom de votre fichier : " & NomPdf)
                 MsgBox (" Le chemin de ce fichier est : " & ThisWorkbook.Path)
 End Sub