controlling word documents from within a c# windows application
Posted on 2006-06-27
I'm developing an c# windows application where part of the procedure is to create word procesesed documents and store them in SQL DB. I'm using Word 11.0 with interop facilities. I've managed to trap the word's quit event from within C# so that if the user quits word, C# will know about this and therefore drop the reference to it. I was hoping to retrieve the doc.Contents.Text stuff before it actually closes word, but this doesn't, as it looses the document first, then passes to the quit function.
I then found the DocumentBeforeSave event, which will call my defined function before word actually tries to save it (if changes were made, a prompt appears).
Ok, so now I'm trapping the BeforeSave, retrieving the contents of the word document to put into a text SQL database field, along side a couple of other bits and pieces of information. I was then hoping for word just to quit (without the save file dialog prompted), but I get the error - word cannot quit while the file dialog box is open.
Is there anyway round this? How can I stop that file dialog appearing, still get the contents of the word doc and close it without any prompts (I'm using get_XML, InsertXML).
Many thanks for any help