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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim pdfjob As Object
Dim nompdf As String
Dim stChemin As String
Dim ficpng As String
Dim DateRecup As Double
'=================================================
' Sauvegarde de la PJ sur HDD
'=================================================
Sub script(BonPng As MailItem)
Set fichier = BonPng.Attachments
Repertoire = "C:\BonsSav\"
DateRecup = Now
fichier(1).SaveAsFile Repertoire & DateRecup & "-" & fichier(1).FileName
'=================================================
' Convertir PJ png en PDF
'=================================================
nompdf = Left(fichier(1), Len(fichier(1)) - 4) & ".pdf"
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = "c:\BonsSav\"
.cOption("AutosaveFilename") = nompdf
.cOption("AutosaveFormat") = 0
.cDefaultPrinter = "PDFCreator"
.cClearCache
End With
End With
ActiveDocument.PrintOut Copies:=1
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
pdfjob.cClearCache
DoEvents
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
GImp.oMonwd.activeprinter = Imprimante_defaut
pdfjob.cClose
Set pdfjob = Nothing
'================================================
' Impression automatique du PDF généré
'================================================
'ShellExecute 0&, "Print", nompdf, "", "", 0&
End Sub |
Partager