Sub ImpressionPdf()
For i = 1 To 66
Range("A1").Select
ActiveCell.FormulaR1C1 = i
Application.Run "echelleCT" 'Macro qui ajuste automatiquement l'échelle du graphique
Range("A1").Select
PdfCreator
Next
End Sub
' Module PDF
Sub PdfCreator()
Dim jobPDF As Object
Dim sNomPDF As String
Dim sCheminPDF As String
Jour = Format(Now(), "ddmmyyyy")
sNomPDF = Jour & "_" & Range("A40")
sCheminPDF = "C:\Documents and Settings\xxxxxxxxxx\test"
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set jobPDF = CreateObject("PDFCreator.clsPDFCreator")
With jobPDF
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Initialisation de PDFCreator impossible", vbCritical + vbOKOnly, "PDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sCheminPDF
.cOption("AutosaveFilename") = sNomPDF
'0=PDF, 1=Png, 2=jpg, 3=bmp, 4=pcx, 5=tif, 6=ps, 7=eps, 8=txt
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Fichier dans la file d'attente
Do Until jobPDF.cCountOfPrintjobs = 1
DoEvents
Loop
jobPDF.cPrinterStop = False
'Attendre que la file d'attente soit vide
Do Until jobPDF.cCountOfPrintjobs = 0
DoEvents
Loop
jobPDF.cClose
Set jobPDF = Nothing
End Sub