Word.Application.Quit(0) taking over 10 seconds in Office 2016 RRS feed

  • Question

  • 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

    • Edited by rozeboosje2 Monday, November 26, 2018 2:58 PM
    Monday, November 26, 2018 2:57 PM

All replies

  • Hi rozeboosje2,

    I suggest you could use the Close method, please see the following example:

    -- to open a document:

    Function CreateMSWordDocument As Variant
        Dim msWord As Variant
        On Error Goto CreateNewInstance
        Set msWord = GetObject("", "Word.Application")
        Set CreateMSWordDocument = msWord
        Exit Function
        Print "Loading Microsoft Word.... Please Wait...."
        Err = 0
        Set msWord = CreateObject("Word.Application")
        Print "Microsoft Word Loaded"
        Resume Done
    End Function
    Set wdDoc= CreateMSWordDocument

    -- to close it again:

    Sub Close
        Call wdDoc.Close
    End Sub

    For more information, please refer to the following links:

    Word.Application (Office 2016) object .quit() method

    Application not quitting after calling quit

    WinWord.exe won't quit after calling Word.Documents.Add - Word .NET Interop

    Hopefully it helps you.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Edited by Lina-MSFT Tuesday, November 27, 2018 2:57 AM
    Tuesday, November 27, 2018 2:56 AM
  • Hi rozeboosje2,

    Thanks for your asking. Please remember to mark the replies as answers if they helped and please help us close the thread.


    Thank you for understanding. If you have any question, or update, please feel free to let us know.


    I wish you a happy life!


    Best Regards,



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, November 29, 2018 7:50 AM