Aleksey Nagoga.

Hi All,

I found a great deal of information on how to customize the Ribbon UI by overriding the RequestService method. The problem is that this method is invoked automatically only once when my add-in is initializing (i.e MS Office Word 2007 is opening)

I, on contrary, need to modify the Ribbon UI based on certain user action - like opening a particularly named document.

Should I keep searching for a way to make the system re-invoke the RequestService method Or should I always create my custom Ribbon UI tab on add-in initialization and keep it hidden until user opens the expected document (if ever). The second approach doesn't look very attractive or elegant, so I assume that there must be another, better way.

Any idea

Thanks.



Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

Cindy Meister

Hi Aleksey

You can invalidate the Ribbon / controls, which will make the Office app re-evaluate and rebuild the ribbon.

A good place to discuss working with the ribbon is the forum at pschmid.net; lots of information there, too.






Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

Aleksey Nagoga.

Thank you, Cindy.

If I understand correctly Invalidate method belongs to IRibbonUI object, which is available only upon creation of my custom ribbon object through the OnLoad method. Since I don't have the object created yet, I therefore can't access and use Invalidate. Unless there is another way of obtaining the needed instance of IRibbonUI object that I'm not familiar with. Is there

Thank you for mentioning pschmid.net, I'll check it out

Aleksey





Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

Aleksey Nagoga.

I ended up creating an instance of my custom ribbon every time the Word opens and making it invisible using getVisible xml attribute until the needed document is loaded. What's interesting is that initially I was using the xml attribute visible instead, but for whatever reason the control's visibility wasn't changing more than once even after calling the Invalidate method.

Having the custom ribbon always preloaded gives me an instance of IRibbonUI, so now I can track events such as DocumentOpen and WindowActivate and Invalidate (i.e. refresh) the custom ribbon based on the user activities.

Creating and loading the IRibbonUI on demand would be more elegant and less resource-consuming, but on the other hand it probably works faster as it is, as all my custom objects (ribbons, panes, etc) are already preloaded.

What I'm still wondering about is whether my approach is how this supposed to be done by design or what I did is more like a workaround.





Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

Cindy Meister

Hi Aleksey

I'm not sure I understand your scenario, but it would be better to ask in the forum I mentioned...

Fact is, the Ribbon is loaded once for the application or for a document window (a customized Ribbon can be stored in an Office document). If it doesn't load your Ribbon, including the necessary callbacks for later manipulating it, then you have absolutely no chance of affecting the Ribbon. There is no object model outside the XML and the callbacks it allows.

You need to declare everything the Ribbon will hold as part of the Ribbon XML that's being loaded.

I don't know if that answers what you're looking for, or not.






Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

savi_hk

Hi Cindy,
In the above post, you said "Ribbon is loaded once
for a document window (a customized Ribbon can be stored in an Office document)". How can we store Ribbon for a particular document only. Is there any help available on this

The problem I am facing is, my Ribbon has the same status across all documents, but the Custom task Pane associated with this is not available in other documents. To explain this scenario clearly, I have ribbon, which has login and few more buttons for some other action. On click of each of these buttons in Ribbon, say Login button, I am loading an usercontrol in customTaskPane. This works fine with the first document that I open. If I open one more new document, then I can see my ribbon with the same status(enabled/Disabled etc) as in first document. But when I click on these buttons, Custom Task Pane is not opened.

As I can see CustomTaskPaneCollection is at Application. So I guess, my task pane, that I created should be available across document. Or, if I want to have, complete different set of custom task pane and ribbon for each document, how can I achieve this

Regards,
Savita




Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

Cindy Meister

Hi Savita

savi_hk wrote:

In the above post, you said "Ribbon is loaded once
for a document window (a customized Ribbon can be stored in an Office document)". How can we store Ribbon for a particular document only. Is there any help available on this

The problem I am facing is, my Ribbon has the same status across all documents, but the Custom task Pane associated with this is not available in other documents. To explain this scenario clearly, I have ribbon, which has login and few more buttons for some other action. On click of each of these buttons in Ribbon, say Login button, I am loading an usercontrol in customTaskPane. This works fine with the first document that I open. If I open one more new document, then I can see my ribbon with the same status(enabled/Disabled etc) as in first document. But when I click on these buttons, Custom Task Pane is not opened.

As I can see CustomTaskPaneCollection is at Application. So I guess, my task pane, that I created should be available across document. Or, if I want to have, complete different set of custom task pane and ribbon for each document, how can I achieve this

In order to have a Ribbon particular to a document, the Ribbon must be defined in the document's XML and all the callback code must be in VBA in the document (as macros).

The problem you describe is known, and is particular to Word, with its pseudo-SDI interface. Here are some discussions in this group that might give you some ideas

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1089531&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1498539&SiteID=1






Re: Visual Studio Tools for Office Customizing Office 2007 Ribbon on demand

savi_hk

Hi Cindy,
Thank you for the help.
The link http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1206919&SiteID=1 really helped me.