mathmax

Hello,

I would like to know if it is possible to customize the rubbon of word 2007 not at the application level but at the document level.
I mean the customizations should appear only for a specific word document.

Thanks,

mathmax


Re: Visual Studio Tools for Office Customize rubbon for a document only.

Mary Lee - MSFT

Hello mathmax,

The short answer is Yes! The "Custom Ribbon UI" column of the "Comparison of UI features" table on http://msdn2.microsoft.com/en-us/library/bf08984t(VS.90).aspx does show that the Ribbon can be used for both document-level customizations and application-level addins.

m.





Re: Visual Studio Tools for Office Customize rubbon for a document only.

mathmax

That's nice. But is there a possibility to interact with the wordDocument or to have acces to the ribbon in the ThisDocument class How

mathmax




Re: Visual Studio Tools for Office Customize rubbon for a document only.

Vladimir Morozov (MSFT)

Hi mathmax,

We have changed the API responsible for accessing Ribbon instances between Beta 2 and RTM.

In Beta 2 you could access ribbons using RibbonManager class:

Ribbon1 ribbon1 = RibbonManager.GetRibbon<Ribbon1>();

foreach (OfficeRibbon ribbon in RibbonManager.Ribbons)

{ /* iterate through all ribbon instances */ }

In RTM we have changed it to use Globals class:

Ribbon1 ribbon1 = Globals.Ribbons.Ribbon1;

foreach (OfficeRibbon ribbon in Globals.Ribbons)

{ /* iterate through all ribbon instances */ }

Thank you,

Vlad





Re: Visual Studio Tools for Office Customize rubbon for a document only.

mathmax

Hi,

Ribbon1 ribbon1 = RibbonManager.GetRibbon<Ribbon1>();

foreach (OfficeRibbon ribbon in RibbonManager.Ribbons)

{ /* iterate through all ribbon instances */ }


Don't work by me : RibbonManager.Ribbons returns an empty collection and RibbonManager.GetRibbon<Ribbon1>() returns null.

But I solved my problem by overriding the CreateRibbonExtensibilityObject method in the ThisDocument class :

private Ribbon1 CustomRibbon;

protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
CustomRibbon = new Ribbon1();
return new Microsoft.Office.Tools.Ribbon.RibbonManager(new Microsoft.Office.Tools.Ribbon.OfficeRibbon[] { CustomRibbon });
}

What is the rtm version Is it the final version When will it be available Will it be free to download




Re: Visual Studio Tools for Office Customize rubbon for a document only.

Vladimir Morozov (MSFT)

I glad that you found a good solution. This scenario will be not changed in the RTM version.

You are right the RibbonManager API only returns ribbon instances used by the application and it will return not null only when Ribbon is already shown to the user.

Globals.Ribbons.Ribbon1 will return not null because it returns a ribbon "prototype", a single instance created per Ribbon. I.e. internally it will be very similar to your code.

BTW, RibbonManager may accept a variable list of ribbons and you can simply write

return new Microsoft.Office.Tools.Ribbon.RibbonManager(CustomRibbon);

RTM is the final version of the Visual Studio 2008. Please watch for official announcements about its release date.

I cannot answer your question if it will be free to download - please see official information about VS 2008 pricing.

Thank you,

Vlad