Word 2007: Customizing Document inspector leaves instance of Word open in the memory.

 

Symptoms:

If you have customized Document inspector for Word 2007 using IDocumentInspector interface, after running the Document Inspector on the document and then exiting out of Word, will leave an instance of the application in memory

Cause

When you invoke the Document inspector, you pass in the Document object to the Inspect and the Fix methods. When you close the main document, the document object passed to the IDocumentInspector is still not released and Word stays in the memory and never exits.

This is known issue reported with the Document Inspector.

Resolution

To resolve the issue you need to NAR (Null and Release) all the document objects you use in your code. Here’s the article that talks about how to implement this in C# and VB.NET in the following KB article.

Office application does not quit after automation from Visual Studio .NET client

https://support.microsoft.com/?id=317109