.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:
- check if document saved. if not ==> ask save , yourself.
- close document yourself
- close word
after these things taken care of, can stuff. lock should released.
Comments
Post a Comment