Eric Li wrote:
I am using C# program 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". How do I create event handler for document closed?
Hi Eric,
the DocumentClass offers a DocumentEvents_ Event_Close. The following
code works for me (Word 2003 and PIAs installed):
private void button1_Click(o bject sender, System.EventArg s e)
{
ApplicationClas s app = new ApplicationClas s();
object miss = System.Type.Mis sing;
DocumentClass doc = (DocumentClass) app.Documents.A dd(ref miss, ref
miss, ref miss, ref miss);
app.Visible = true;
doc.DocumentEve nts_Event_Close +=new
DocumentEvents_ CloseEventHandl er(doc_Document Events_Event_Cl ose);
}
private void doc_DocumentEve nts_Event_Close ()
{
MessageBox.Show ("Close event");
}
Cheers
Arne Janning