document.Close() is causing the application to close in Word 2010 - any way to prevent this? RRS feed

  • Question

  • I have coded an add-in that saves a document locally, then zips it up and sends it back to a server for storage there. Optionally, if the user has indicated that he is done working with the document, it also closes the document if everything was handled successfully. In Word 2007, if this is the only document that is still open, Word remains open with no active document (desired behavior). However, in Word 2010, if the only remaining document is closed using the document.Close method, then then entire Word application is shut down and must be re-opened. If this happens, then the add-in has forgotten the current user's password for the server access and the user will have to re-enter it the next time they try to save a document back to the server, which is an irritation.

    So - is there any way to prevent the application shutdown in Word 2010 when doing a document.Close?

    Wednesday, March 16, 2011 2:24 AM


  • Hi Lynae,

    Thanks for posting in the MSDN Forum.

    Do you want to close the document but the word application is not quit?  If you want to do that please use this snippet.

    Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
    Word.Application app = Globals.ThisAddIn.Application;

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 17, 2011 8:52 AM