Word Add-In Task Pane with Multiple Instances of Word open

Add-in Express™ Support Service
That's what is more important than anything else

Word Add-In Task Pane with Multiple Instances of Word open
 
Chris McA


Guest


I am developing an Add-in for Word that reacts based on the content of the current open document. I have an instance of a Task Pane that works perfectly when there is a single instance of Word open, however I am having problems when there are multiple instances of Word open, with the content of the panel not remaining unique to the document in its instance of Word.

Do you have any advice on how to manage individual instances of Task Pane so that they remain isolated to one document and do not get affect by any other documents that are open at the same time?

I also have hooked up some of the Word events to detect when documents are being opened, both new blank documents and existing documents. When a new document is opened and it is the first instance of Word it works fine, I can see the Panel_Loaded event being fired and I have been able to log the Doc ID for the new document from an event handler for Word?Â?Ð?és new document event. I have a problem when any subsequent new documents are open, the Panel_Loaded event is again being called, but the NewDocument event handler isn?Â?Ð?ét being correctly called, so I am unable to get the Doc ID of the new document.

Do you know if there is a best practice way to hook up the Document opened/created events to manage Task Pane instances, or a way to do this without using the Word events?
Posted 12 May, 2017 06:15:03 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Chris,

To have the unique content, put your controls on a UserControl, put the UserControl on a pane, and bind the UserControl to a document.

Chris McA writes:
I also have hooked up some of the Word events to detect when documents are being opened


To make sure that you understand how Add-in Express panes operate, check section Accessing a Form Instance at https://www.add-in-express.com/docs/net-outlook-regions-panes-ui.php#form-instances-programmatically.

Chris McA writes:
I have a problem when any subsequent new documents are open, the Panel_Loaded event is again being called, but the NewDocument event handler isn?Â?Ð?ét being correctly called, so I am unable to get the Doc ID of the new document.


Call ADXWordTaskPane.WindowObj. It returns a Word.Window object - it is a COM object that you must release after use - representing the Word window that the pane is associated with. Call Window.Document to get the document that the window displays.


Andrei Smolin
Add-in Express Team Leader
Posted 12 May, 2017 08:19:15 Top
Chris McA


Guest


Great, thanks Andrei!
Posted 26 Jun, 2017 06:45:26 Top