bonjour, j'ai trouvé ca sur un site mais ca bug, pouvez vous m'aider
Sub testPrintPDF()
Dim oldPrinter As String
Dim stChemin As String
Dim stNom As String
' Affichage de la fenêtre de PDF
Shell "C:\Program Files\PDFCreator\PDFCreator.exe", vbNormalFocus
Dim PDFCreator1 As New clsPDFCreator (c'est la que ca bug)
oldPrinter = ActivePrinter
'On va mettre en mémoire dans une
'variable le nom de l'imprimante par défaut
ActivePrinter = "PDFCreator"
'Mettre comme imprimante par défaut PDFCreator
If Len(ActiveDocument.Path) = 0 Then
stChemin = "c:\temp"
Else
stChemin = ActiveDocument.Path
End If
'Si le document n'a pas été sauvegardé, le PDF sera dans le répertoire c:\temp
'et un nom par défaut documentPDF;pdf
If Len(ActiveDocument.Name) = 0 Then
stNom = "documentPDF.pdf"
Else
stNom = ActiveDocument.Name
End If
'les option PDFCreator
With PDFCreator1
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = stChemin
.cOption("AutosaveFilename") = stNom
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cStart
.cClearCache
End With
ActiveDocument.PrintOut Background:=True
PDFCreator1.cClose
ActivePrinter = oldPrinter
' Change l'imprimante par défaut
End Sub
Sub testPrintPDF()
Dim oldPrinter As String
Dim stChemin As String
Dim stNom As String
' Affichage de la fenêtre de PDF
Shell "C:\Program Files\PDFCreator\PDFCreator.exe", vbNormalFocus
Dim PDFCreator1 As New clsPDFCreator (c'est la que ca bug)
oldPrinter = ActivePrinter
'On va mettre en mémoire dans une
'variable le nom de l'imprimante par défaut
ActivePrinter = "PDFCreator"
'Mettre comme imprimante par défaut PDFCreator
If Len(ActiveDocument.Path) = 0 Then
stChemin = "c:\temp"
Else
stChemin = ActiveDocument.Path
End If
'Si le document n'a pas été sauvegardé, le PDF sera dans le répertoire c:\temp
'et un nom par défaut documentPDF;pdf
If Len(ActiveDocument.Name) = 0 Then
stNom = "documentPDF.pdf"
Else
stNom = ActiveDocument.Name
End If
'les option PDFCreator
With PDFCreator1
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = stChemin
.cOption("AutosaveFilename") = stNom
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cStart
.cClearCache
End With
ActiveDocument.PrintOut Background:=True
PDFCreator1.cClose
ActivePrinter = oldPrinter
' Change l'imprimante par défaut
End Sub