Using Ribbons with Mixed-Version Addin

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

Using Ribbons with Mixed-Version Addin
 
Rick Koch




Posts: 172
Joined: 2006-09-05
Using .Net 2009 ADX, set to be version neutral running both OL2003 and OL2007.

I realize legacy CommandBar buttons are visible on the Inspectors' Add-Ins tabs. But would it be possible to add custom control groups to ribbons within Outlook 2007 instead?

I would use all the same code to process events in both versions, but in OL2003 I would add buttons to Microsoft's CommandBars, while in OL2007 I would want to add custom control groups to the corresponding Microsoft ribbons instead. Can this be done? The OL2007 control groups would feature all the same buttons added to CommandBars in OL2003.

The question is: What to do with the CommandBar buttons in OL2007? I could wrap all the Inspector button initialization in if...then...else blocks, but a lot of that is done in generated code, and I don't want to break the designer.

Or I could add a step, at the end of initialization, that hides all the Inspector buttons in OL2007 (since Explorer buttons are still used in OL2007). Would that work?

I've also considered simply writing two Outlook-version-specific versions of my addin, and then letting the installer decide which one to put on each platform at install-time.

What's the best way to leverage the Ribbon in my version-independent addin?
Posted 20 Apr, 2010 15:13:05 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Rick,

You need to set UseForRibbon = False in all command bar components and add a Ribbon tab component onto your add-in module and populate the tab with Ribbon controls. That's all. No IFs, no add-in versions, nothing.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Apr, 2010 03:43:16 Top
Rick Koch




Posts: 172
Joined: 2006-09-05
That's wonderful! I'm so glad I went with this product.

Is it customary to manage a single Ribbon across different Inspectors, or do I define a different Ribbon for each type?
Posted 21 Apr, 2010 09:38:03 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Rick,

In fact you are free; if you need to show a single button in different Ribbons, see the Ribbons property of the Ribbon Tab component.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Apr, 2010 11:31:29 Top
Rick Koch




Posts: 172
Joined: 2006-09-05
I'm trying to compare what the designer creates with what the Ribbon requires. I can't see the XML. I want to display my own Ribbon groups on Microsoft's default Ribbons in Outlook. Can I use the designer for any of this? Can I access the XML returned by the generated controls?
Posted 21 Apr, 2010 14:53:52 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Rick,

private void AddinModule_OnRibbonBeforeLoad(object sender, AddinExpress.MSO.ADXRibbonBeforeLoadEventArgs e)
{
    //Pass the filepath and filename to the StreamWriter Constructor
    StreamWriter sw = new StreamWriter("D:\myRibbon.txt");
    //Write a line of text
    sw.Write(e.Xml);
    //Close the file
    sw.Close();
}


There's no way to add a custom control to a built-in Ribbon group. But you can add a custom Ribbon group onto a built-in Ribbon tab: specify the Id of that tab in the IdMso property of the Ribbon tab component. You can download IDs of built in controls at Microsoft; for Office 2007, see http://www.microsoft.com/downloads/details.aspx?FamilyID=4329d9e9-4d11-46a5-898d-23e4f331e9ae&DisplayLang=en; for Office 2010, see http://www.microsoft.com/downloads/details.aspx?FamilyID=3f2fe784-610e-4bf1-8143-41e481993ac6&displaylang=en. The download installs Excel files; the Control Name column of each contains the IDs of almost all built-in Ribbon controls for the corresponding Ribbon.


Andrei Smolin
Add-in Express Team Leader
Posted 22 Apr, 2010 02:59:55 Top
Rick Koch




Posts: 172
Joined: 2006-09-05
So if I understand this, ADX-generated Ribbon XML is not available at design-time. So, using your method above, I can retrieve the XML while running my addin, and then I can adapt the XML to form the groups I want to add to Microsoft's default Ribbons. The final version of the addin would have to be modified to return my custom Ribbon XML instead of the designer's XML -- I suppose that once I've generated the XML I won't need the ADX Ribbon components in the code anymore.

Is that correct?

Wait, I'm re-reading your post -- and I can specify the Microsoft tab ID in the designer?
Posted 22 Apr, 2010 09:54:20 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Rick,

Yes, what you need is to specify the id of the built-in Ribbon tab in the Ribbon tab component.


Andrei Smolin
Add-in Express Team Leader
Posted 22 Apr, 2010 10:41:56 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Rick,

I'm sorry, I should have said: " what you need is to specify the id of the built-in Ribbon tab in the IdMso property of the Ribbon tab component."

Say, the following code in InitializeComponent adds a custom Ribbon group with a Ribbon button on a custom Ribbon tab:

// 
// adxRibbonTab1
// 
this.adxRibbonTab1.Caption = "adxRibbonTab1";
this.adxRibbonTab1.Controls.Add(this.adxRibbonGroup1);
this.adxRibbonTab1.Id = "adxRibbonTab_786966392286428ebd25609e72b6c682";
this.adxRibbonTab1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
// 
// adxRibbonGroup1
// 
this.adxRibbonGroup1.Caption = "adxRibbonGroup1";
this.adxRibbonGroup1.Controls.Add(this.adxRibbonButton1);
this.adxRibbonGroup1.Id = "adxRibbonGroup_f933fd56cb51421588c4be48426584cf";
this.adxRibbonGroup1.ImageTransparentColor = System.Drawing.Color.Transparent;
this.adxRibbonGroup1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
// 
// adxRibbonButton1
// 
this.adxRibbonButton1.Caption = "adxRibbonButton1";
this.adxRibbonButton1.Id = "adxRibbonButton_91e115c426d24e69af52ecdd09218c80";
this.adxRibbonButton1.ImageTransparentColor = System.Drawing.Color.Transparent;
this.adxRibbonButton1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;


By setting the IdMso property, you change InitializeComponent; the following code adds the same Ribbon group with the same Ribbon button onto the Home tab:

// 
// adxRibbonTab1
// 
this.adxRibbonTab1.Caption = "adxRibbonTab1";
this.adxRibbonTab1.Controls.Add(this.adxRibbonGroup1);
this.adxRibbonTab1.Id = "adxRibbonTab_786966392286428ebd25609e72b6c682";
this.adxRibbonTab1.IdMso = "TabHome";
this.adxRibbonTab1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;



Andrei Smolin
Add-in Express Team Leader
Posted 22 Apr, 2010 10:59:02 Top
Rick Koch




Posts: 172
Joined: 2006-09-05
This is working very well. We're thrilled to see our buttons on the factory ribbon!
Posted 27 Apr, 2010 17:33:36 Top