Hi,
First, i would like to thanks all the staff for the great job accomplished with that progam !!!
I'm writting a message here because I made a small vba script in Outlook 2007 to convert emails in pdf files that are saved on my computer. In Outlook, I call a Word application to use PDFCREATOR.
The script is working well ... but only one time ! If I try to start it more than once in the same outlook session, PDFCREATOR bugs (there is a red dot and the program seems to do nothing) ... even If I put some process killer at the end of my code ????
Somebody already experienced that ? is there a way to solve that problem ? Thanks in advance !!
Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(strChemin & "\\" & strNomTransfert_doc)
WordApp.Visible = False
'With WordApp.Selection
'.TypeParagraph
'.TypeText Text:=Item.SenderName
'.TypeParagraph
'.TypeText Text:=Item.Body
'.TypeParagraph
'End With
'Lancement de PDFcreator
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Initialisation de PDFCreator impossible", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = strChemin
.cOption("AutosaveFilename") = strNomPDF
.cOption("AutosaveFormat") = 0 '0 pour pdf
.cClearCache
End With
ActivePrinter = "PDFCreator"
WordDoc.PrintOut
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
With pdfjob
.cDefaultprinter = DefaultPrinter
.cClearCache
.cClose
End With
Set pdfjob = Nothing
SuppProcPDFCreator 'destroy pdfcreator
'closing word
WordDoc.Close
WordApp.Quit
Sub SuppProcPDFCreator()
'procédure permettant de détruire l'application PDFCREATOR qui reste ouverte (bug de la dernière version)
MsgBox "KILL !"
Dim RetVal As Variant
RetVal = Shell("Taskkill /IM PDFCreator.exe /F", 0)
End Sub