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 39
|
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")
Sheets(Array("Feuil2", "Feuil3")).Select
If IsEmpty(selection.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
ActiveWindow.SelectedSheets.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 |