Word Addin - document command bars

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

Word Addin - document command bars
 
ron vader




Posts: 8
Joined: 2006-08-28

I am writing an addin for Word in which I would like to create a new and distinct custom command bar for each document that is opened (new or existing).

the Word object model enables access to command bars through both the application object and the document object. I'm assuming that the Application.CommandBars object is intended for consistent use across all open documents. I am interested in creating a custom command bar that maintains specific attributes respective to it's 'owner' document.

to exemplify my problem with the above, I have written a prototype where I have created an Application level command bar which contains a single CommandBarButton control. when a document is opened, the caption of the button is updated to reflect the name of the document. when I activate a second document the CommandBarButton control is updated as expected, however (and not entirely unexpectedly) the button control in the first document instance is also updated with the filename of the new document. what I would like to achieve is that the CommandBarButton maintain the respective document filename as the caption regardless of which document is active. (please note, this is not my intended functionality, this is simply a scenerio to exemplify my problem).

it is not however abundantly apparent how this is achieved using ADX.NET. I've tried a number of different approaches and in general to no avail.

I would otherwise also entertain any solution which would enable me to achieve the above with the Application.CommandBars object.

any insight would be much appreciated.

ron.

Posted 28 Aug, 2006 16:11:08 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Ron.

I think that the 'ADX Word Document Module' wizard will help you to create the document/template based add-in. Please look at the WordFax example from the ADX installation package.
Let me know if you face any difficulties with the code.
Posted 29 Aug, 2006 07:38:44 Top
ron vader




Posts: 8
Joined: 2006-08-28
thanks for the quick response, Sergey.

I've had a look at the Fax Demo as you suggested and tweaked the FaxModule code to simulate the example I explained previously. still, when I open multiple documents, the button caption in all instances of the "Word Fax Bar" are updated to the filename of the active document.

I tried setting the ADXCommandBar.Context (which is apparently consistent with the CustomizationContext property) to the document file name when the FaxModule.OnWindowActivate event is fired. this seems to be the first opportunity to get a reference to a newly opened document. this is essentially what I've done previously with good old fashioned C++ COM Addins and yields the desired results. however I still cannot reproduce this functionality with the ADX components.

what have I missed?

thanks again, ron.

Posted 29 Aug, 2006 09:53:27 Top
ron vader




Posts: 8
Joined: 2006-08-28
hi Sergey,

I'm still looking for a solution. I've continued to experiment with this but still cannot achieve the desired results.

any further detail would be very much appreciated.

thanks, ron.
Posted 30 Aug, 2006 09:58:22 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Ron.

I am afraid that you will have to create command bars manually. The fact is that ADX components will not work correctly if you change the Context and CustomizationContext properties. Try to implement the C++ add-in functionality without using ADX components.
Posted 31 Aug, 2006 16:06:20 Top