Word add on is not working properly when more than one word app is running in computer
-
Thursday, May 10, 2012 10:41 AM
hello,
I am facing very strange problem with my word on. It's working fine when I try to run it from visual studio. But If i deploy that in any machine and one or more word document are opened up then it does not invoke.
Basically, as per our requirement our word add on does not invoke code every time it checks few properties of current word document and if it finds, then word add on code execute. It Works fine when any one document is opened up.
Add on code does not work well when we have more than one word application opened up. Is there any configuration, should be done for running code when we have more than one word app running in machine?
Please note that we have created office word 2007 add on with visual studio 2010.
Thanks and Regards,
Shailesh B. Davara
- Edited by Shailesh B Davara Thursday, May 10, 2012 10:51 AM
All Replies
-
Thursday, May 10, 2012 11:46 AM
No, there shouldn't be anything special you need to do for coping with multiple instances of Word being open.
This is an application level add-in? Are you putting code in a start up handler? If so, when you open multiple documents (in fact the same instance of Word) the add-in will be loaded with the first one, and your initialisation code might not run. If this is the case, what you need to do is handle the event of a new document being opened, and have your initilisation code run there too.
-
Thursday, May 10, 2012 1:31 PMModerator
Hi Shailesh
In addition to what Joseph asks, could you please describe what your add-in should do, that it's not doing? Should it be showing a task pane, for example?
Cindy Meister, VSTO/Word MVP
-
Friday, May 11, 2012 5:21 AM
hi Cindy Meister,
yes sure, let me explain work of my add on.
Main purpose of my word add on is to copy my word document to server. At the application close event, we placed code for checking if this is the document which we wish to store (it depends on some properties of document i.e author, description etc) in server? if yes, then at the application shut down even we placed code for asking to save this document to server.
On the click of yes, all data will be saved to server with use of web service call. It works when we have only one document opened up in pc, but it creates problem when we have more than one document opened up.
In case of more than one document, dialog box for saving document to server does not come up, and it just close application. Its strange, it works fine when I debug in vs.
Thanks and Regards, Shailesh B. Davara
-
Friday, May 11, 2012 1:31 PMModerator
Hi Shailesh
<<In case of more than one document, dialog box for saving document to server does not come up, and it just close application. Its strange, it works fine when I debug in vs.>>
This sounds like a "race condition" to me. I think that when the application shuts down it is too late - the documents will be (partially) unloaded already.
Have you tried using the event that triggers when a document closes (DocumentBeforeClose)? This will certainly let you take the necessary steps while the document is still loaded in memory ("before close").
Cindy Meister, VSTO/Word MVP
- Marked As Answer by Shailesh B Davara Friday, May 18, 2012 6:03 AM
-
Tuesday, May 15, 2012 5:33 AM
hi Cindy Meister,
I handled that(DocumentBeforeClose) event and application shutdown too. Let me try to use only DocumentBeforeClose event for handling our task.
thanks.
Thanks and Regards, Shailesh B. Davara
-
Friday, May 18, 2012 6:24 AM
Hi Cindy Meister,
I tried your solution and it's working and it identifies particular document when more than one document is running on.
I'll need to go through some test cases for this. but hopefully it will work.
Thanks.
Thanks and Regards, Shailesh B. Davara
-
Friday, May 18, 2012 6:54 AMModerator
Hi Shailesh
Glad things are moving in the right direction :-)
Cindy Meister, VSTO/Word MVP

