.net - Start Word and monitor if document closed -


we need our school project way start word instance , track if document closed. com api word doens't have event this, there other ways this?

currently we're using com api word, else fine. we're programing in c#.

if using microsoft.office.interop.word library there event can subscribe too:

microsoft.office.interop.word.application wordapp =     new microsoft.office.interop.word.application(); wordapp.documentbeforeclose +=     new applicationevents4_documentbeforecloseeventhandler(         wordapp_documentbeforeclose); 

...

private void wordapp_documentbeforeclose(document doc, ref bool cancel) {     // thing } 

edit:

to take care of file lock ==> take @ this post. can see there few things done in documentbeforeclose:

  1. check if document saved. if not ==> ask save , yourself.
  2. close document yourself
  3. close word

after these things taken care of, can stuff. lock should released.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -