I’m using the following code:
using MSWord = Microsoft.Office.Interop.Word;
.
.
.
MSWord.Application wordApp = new MSWord.Application();
MSWord.Document wordDoc = new MSWord.Document();
wordDoc = wordApp.Documents.Add(Template: oTemplatePath);
//do something with the Document... replace fields and so on...
wordApp.Visible = true;
the function then exits and my app is closing down, for example.
Now the user can edit the open document, and save it or just close it.
Do I have to close the Application-Object (in terms of COM-Objects and so on) programmatically??? Or does this the Garbage collector?
If you want to correctly close / dispose COM Objects when using Microsoft.Interop
you would want to use this method
so for example if I have created an object named wordApp I would declare it like this and dispose it like the following
This can give you an example of how to use ReleaseComObject
Marshal.ReleaseComObject Method