Hello all. We have just come across a very strange issue with some of our users who are on Office 365 (Office 2016?)
Outlook for Office 365 16.0.11001.20097
Word for Office 365 - same
We wrote an Add-in which allows users to pick a document, and it then converts this document to PDF and attaches it to the email they are composing.
The relevant code looks like this:
oWord = New Microsoft.Office.Interop.Word.Application
oDoc = oWord.Documents.Open(strOriginalFileDoc) 'temp location where the original file is stored With oDoc .ExportAsFixedFormat(OutputFileName:=strOriginalFileDoc.Substring(0, strOriginalFileDoc.LastIndexOf(".")) + ".PDF", ExportFormat:=Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, Item:=Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentWithMarkup) .Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges) End With oWord.Quit(0)
After the Word.Application is Quit, the "file selection" dialog is closed (this is important, see below)
please note that the same issue happens with exporting wdExportDocumentContent
I have removed irrelevant code like error handling and Marshaling code to release COM objects etc. Please let me know if you think this IS relevant and I will re-post full code
Here is the problem: This add-in has worked just fine for years, through Office 2010 and Office 2013, never did we have a problem. In THIS version of Office, however, we get some strange behaviour. After attaching a document that is converted to PDF, *sometimes*
Outlook appears to "hang". The .PDF is now shown in the attachments of the message that the user is composing, but the message is "inaccessible". When the user types text on the Keyboard, nothing seems to be happening. The user cannot click
into the TO, CC, BCC or Body boxes. After several seconds it all "comes good". If the user typed in any text, this "buffered" text suddenly appears and the Message is once again accessible for composing.
We observe the following when this occurs:
1) The "file selection" dialog closes immediately without delay. This means that the code executes the .Quit(0) command AND proceeds afterwards without delay.
2) In Windows Task Manager we observe that WINWORD.EXE continues running for as long as the Message that the user is composing remains "inaccessible". The point at which the message becomes accessible again coincides with the point at which WINWORD.EXE finally closes.
3) We disabled and removed ALL Add-ins (COM as well as otherwise) that were active on Word, to no avail.
4) Whatever is causing this "hang" is NOT happening during the call to .Quit(0) as the code happily proceeds to the next statement. We were therefore able to implement functionality that checks whether WINWORD.EXE is still running half a second
after the .Quit(0) is called on the Application, and forcibly kills the Process if that is the case (with precautions to ensure we don't kill Word processes that aren't ours or that were already running). Obviously we're not happy having to implement this"Brute Force" approach to the problem.
Any advice would be welcome