Dolichotis
XLDnaute Occasionnel
Bonjour,
J'ai trouvé un code qui permet d'avoir un document PDF d'une sélection d'une feuille Excel.
Je l'ai adapté pour mon usage personnage, ça fonctionnait parfaitement mais maintenant ça me créé un document pdf vide !!
Ai-je changé une chose qui ne fallait pas ? J'ai regardé le code sous tous les angles, je n'ai pas trouvé !
Si vous pouviez regarder mon code et me dire ce qui ne va pas avec, je vous remercie !!
J'ai trouvé un code qui permet d'avoir un document PDF d'une sélection d'une feuille Excel.
Je l'ai adapté pour mon usage personnage, ça fonctionnait parfaitement mais maintenant ça me créé un document pdf vide !!
Ai-je changé une chose qui ne fallait pas ? J'ai regardé le code sous tous les angles, je n'ai pas trouvé !
Code:
'imprimer un document pdf
Dim PDFdoc As PDFCreator.clsPDFCreator
Set PDFdoc = New PDFCreator.clsPDFCreator
Dim sPDFName As String, sPDFPath As String
Dim RetVal As Variant, Area As String
ChArch = "" & chemin & "\Archives\" & Application.PathSeparator
NameArch = "" & TypOuvr & "ref" & Ref & "VISA.pdf" 'nom du PDF
Area = "D33:F44"
With PDFdoc
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
RetVal = Shell("Taskkill /IM PDFCreator.exe /F", 0)
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = ChArch
.cOption("AutosaveFilename") = NameArch
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
With wbEx.Worksheets(1).PageSetup 'tout sur une feuille
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
wbEx.Worksheets(1).Activate
wbEx.Worksheets(1).Range(Area).Select
Selection.PrintOut ActivePrinter:="PDFCreator sur Ne00:" 'choix de la zone d'impression
Do Until PDFdoc.cCountOfPrintjobs = 1
DoEvents
Loop
PDFdoc.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until PDFdoc.cCountOfPrintjobs = 0
DoEvents
Loop
PDFdoc.cClose
Set PDFdoc = Nothing 'libérer l'objet
Si vous pouviez regarder mon code et me dire ce qui ne va pas avec, je vous remercie !!