I am using C# program (not addin, just EXE) to launch a Word document in
Word 2003. My C# program
will be sitting on "top most" while document opened. I would like to hook up
an event when Word document has been closed (not Word application), my
program will be closed automatically too.
I can't find the "Close" event in ActiveDocument. There are events for "New"
and "Open". Where is event handler for document close?
Thanks.
Eric
"Eric Li" <ericl...@nospam.hotmail.com> wrote in message
news:OeSsslE...@TK2MSFTNGP11.phx.gbl...
Thanks for your repley. I will try it.
However, if user has two Word documents, switching document will fire up
"WindowSelectionChange" event too, and my EXE will be closed. That's not I
want. How do I know the event is called by document closed or by document
switched? Do you have a way to know?
Thanks.
Eric
"Jezebel" <dwa...@heaven.com.kr> wrote in message
news:OYovZrE...@TK2MSFTNGP10.phx.gbl...
Failing that, you can use the app events (not WindowSelectionChange, my
mistake) but WindowActivate. When fired, you iterate Word's Documents
collection to see if your document is still in it.
"Eric Li" <ericl...@nospam.hotmail.com> wrote in message
news:OX8Gg5ER...@tk2msftngp13.phx.gbl...
Actually my case is kind of complicated. I tried to use
"DocumentClass_DocumentEvents_Event_Close" for Close Event. But, if I close
my EXE in Close Event, my EXE will be getting an error. The reason why is
that my EXE will try to read this document into memory again and upload it
to server before closing itself. Since Close Event is not releasing the
document yet, my EXE can't reload the document.
Finally I figured it out by using the following solution:
1. Fire up Close Event when user clicks "X" on document.
2. In Close Event, I launch a Threading. This threading will check the
document that is holding by Word.
3. The Threading will keep checking the status of document until Word
release the document.
4. My EXE will upload the document to server once Word release the document
5. Close my EXE.
Thanks for your help.
Eric
"Jezebel" <dwa...@heaven.com.kr> wrote in message
news:e4oXsYIR...@TK2MSFTNGP11.phx.gbl...