Bonjour,
Je reviens vers un sujet déjà abordé.
J'ai copié un bout de code et j'aimerai à partir d'un UserForm déclencher cette macro....
Et adjoindre deux feuilles sur un seul PDF...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
Dim ImpPDF As Object
Dim NomPDF As String
Dim RepertoirePDF As String
Dim ClientPDF As String
Dim CheminPDF As String
Dim SheetPDF As String
 
CheminPDF = "C:\MesDocuments\FichierPDF\"
ClientPDF = Sheets("Feuil1").Range("A1").Value
NomPDF = ClientPDF & ".pdf"
RepertoirePDF = NomPDF
SheetPDF = Sheets("Feuil2") & Sheets("Feuil3")
 
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set ImpPDF = CreateObject("PDFCreator.clsPDFCreator")
With ImpPDF
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Impossibilité d'initialiser PDFCréator !", vbCritical + vbOKOnly, "PDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = CheminPDF
.cOption("AutosaveFilename") = RepertoirePDF
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveSheetPDF.PrintOut copies:=1, ActivePrinter:="PDFCreator"
Do Until ImpPDF.cCountOfPrintjobs = 1
DoEvents
Loop
ImpPDF.cPrinterStop = False
Do Until ImpPDF.cCountOfPrintjobs = 0
DoEvents
Loop
ImpPDF.cClose
Set ImpPDF = Nothing
Je déclare SheetPDF, ( 2 feuilles ) Est-ce possible ?
Cette macro fonctionne bien avec une seule feuille.
Est-ce l'UserForm qui fait que ça Bug ??

Bien cordialement