cdamyx / printOutlookAttachments

VBA Macro to print PDF, Word, and Excel attachments of emails in a particular Outlook folder.
MIT License
2 stars 1 forks source link

Multiple PDFs attachments : Handle_MultipleInstance #1

Open DKWien opened 2 years ago

DKWien commented 2 years ago

Hello,

Your code is very good ! Great Job!

When I have an email with 3 pdf attachments:

Dok1.pdf Dok2.pdf Dok3.pdf

Then multiple instances to print the PDF start, but the program does not allow this and I see error message pop-up in windows 10 "PDFtoPrinter.exe is already running. Please wait." In the end only one pdf gets printed.

I get problems with running 3 x pdfprinter.exe (pdfxcview.exe) at nearly same time. It might be because I use a new version of "pdfprinter.exe" from here : http://www.columbia.edu/~em36/pdftoprinter.html

Here : http://www.columbia.edu/~em36/PDFtoPrinter.au3 I find: a piece of code:

Func Handle_MultipleInstance() If _Singleton(StringReplace(@ScriptFullPath, '\', '/'), 1) = 0 Then Local $sMsgBoxMsg = "PDFtoPrinter.exe is already running. Please wait." If $cli = 0 Then MsgBox(0, $msgTitle, $sMsgBoxMsg, 2) Else ConsoleWrite($sMsgBoxMsg) EndIf Exit EndIf EndFunc ;==>Handle_MultipleInstance

For testing I run the same code in batch file test.bat:

@echo on "C:\Users\bgm\AppData\Local\Temp\PDFPrinterTmp\PDFXCview.exe" "/printto:&" "Schmierpapier" "C:\Users\bgm\Documents\OLAttachments\Dok1.pdf" "C:\Users\bgm\AppData\Local\Temp\PDFPrinterTmp\PDFXCview.exe" "/printto:&" "Schmierpapier" "C:\Users\bgm\Documents\OLAttachments\Dok2.pdf" "C:\Users\bgm\AppData\Local\Temp\PDFPrinterTmp\PDFXCview.exe" "/printto:&" "Schmierpapier" "C:\Users\bgm\Documents\OLAttachments\Dok3.pdf" pause

It works without problems.

I have a workaround to slow down the VBA, but this is not perfect, because the waiting time is only an estimation:

Dim TimeEnd As Single TimeEnd = Timer + 2 While Timer < TimeEnd DoEvents Wend

Best regards and thank you in advance.

cdamyx commented 2 years ago

Oh hey, sorry I didn't notice this sooner - thanks for reaching out!

I believe you're correct, there is a newer version of the PDFtoPrinter.exe program, which has introduced a new bug.

I'll look into this new version and make some updates when I get a chance. Currently on the hunt for a new job, so it might be a little bit before I can dig in. I hope you were able to make use of the script with the fix you applied!