I have a requirement to open and manage a Word document, stored on the file system, from .NET code. In particular, I want to be able to show a dialog and possibly submit it to a server when the user closes the Word document in question.
Having experimented and searched a bit, I am not sure how to proceed with this. Possibilities appear to include:
- Using Process.Start and listening for the Exited event.
- Using Microsoft.Office.Interop.Word and then starting the doc through that and listening for the DocumentBeforeClose event.
Neither of these seems to entirely solve the problem, however. (1) because there will only be one Word process running for multiple open documents and the Exited event received will not necessarily correspond to the actual document that my code was responsible for opening. And (2) because it doesn't cope with the case in which Word crashes, and it's a hassle to get the tidying up of those COM objects right.
If anyone has an idea how to proceed with this, or an article that would help, I would be grateful.