Search code examples
c#ms-wordoffice-interop

Documents.Close makes Word visible


I have been trying a workaround for this, for quite a long time, but haven't found one yet. On calling Documents.Close(), Word, which was opened with visible = false, becomes visible.

This is my close statement (document is already saved so no need to save again):

    WordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges,
    Word.WdOriginalFormat.wdOriginalDocumentFormat);

Solution

  • You could just call WordApp.Quit().

    Office apps still follow the MDI approach: You run 1 App and in that app you can open 1 or more documents.

    It's easy to lose track of that App in the background as we usually only open one document. But there are two levels of Close here.