Pino Carafa
Posts: 162
Joined: 2016-09-28
|
Hello Add-in Express,
Just noticed something odd in our Word Add-in. I suspect that this is down to Word itself not playing ball but I thought I'd just mention it here, in case this is something that rings a bell with you?
Scenario 1:
Our application uses WordApplication.Documents.Open to open a document on a user's PC. In our Add-in the AdxWordAppEvents1_DocumentOpen event fires and we "do stuff". The user "forgets" that they have the document already open, and they use our application to open it again. Our application uses WordApplication.Documents.Open to open the same document a second time. Word, however, seems "smart" enough to realise they are opening a document that is already open, so it just activates that document. AdxWordAppEvents1_DocumentOpen does not fire. All is well.
Scenario 2:
Our application uses WordApplication.Documents.Open to open a document on a user's PC. In our Add-in the AdxWordAppEvents1_DocumentOpen event fires and we "do stuff". The user proceeds to open a second document. That second document is now the ActiveDocument. The user "forgets" that they have the first document already open, and they use our application to open it again. Our application uses WordApplication.Documents.Open to open the same document a second time. Word, however, seems "smart" enough to realise they are opening a document that is already open, so it just activates that document. However.... AdxWordAppEvents1_DocumentOpen does fire and we end up "doing stuff" on an open document that we shouldn't be "doing stuff" on.
Like I said, this is no biggie.... The obvious solution for us in our application is to check ourselves whether the document the user is trying to open is already in the WordApplication.Documents list, and then use .Activate() instead of .Open.... but I thought maybe you'd like to know about this. Or is this "expected" behaviour from Word? |
|
Andrei Smolin
Add-in Express team
Posts: 18816
Joined: 2006-05-11
|
Hello Pino,
The description suggests this is an issue in Word. Thank you for sharing this information with forum readers. Many thanks!
Regards from Poland (GMT+1),
Andrei Smolin
Add-in Express Team Leader |
|