Use same Ribbon in Multiple Inspectors

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

Use same Ribbon in Multiple Inspectors
 
Gerhard Grossberger




Posts: 14
Joined: 2011-08-10
I am adding a Ribbon to an ADX-Module that will have the same options for several inspectors. The inspectors should be readmail, appointment, task etc. I managed to attach the ribbon to Readmail using the description here: http://www.add-in-express.com/creating-addins-blog/2011/03/22/office-outlook-word-ribbon-tabs-controls/

Is there a possibility to create only one Ribbon that can be used across all inspectors?

Regards, Gerhard
Posted 01 Sep, 2011 11:30:41 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gerhard,

Yes, there is. Please take a look at the Ribbons property of the ADXRibbonTab component. It looks like you need to customize it.
.NET, Extended MAPI, Windows Phone & RT
Posted 02 Sep, 2011 01:28:38 Top
Gerhard Grossberger




Posts: 14
Joined: 2011-08-10
Hi Eugene,
Thanks for the reply. I figured out this much already and this works ok.
What I didnīt mention was custom placement of Ribbons. When I add an IdMso property to the Ribbon, it is displayed in this position in the Ribbon.


this.myInspectorRibbon.Ribbons = ((AddinExpress.MSO.ADXRibbons)((((AddinExpress.MSO.ADXRibbons.msrOutlookMailRead | AddinExpress.MSO.ADXRibbons.msrOutlookAppointment)
                        | AddinExpress.MSO.ADXRibbons.msrOutlookContact)
                        | AddinExpress.MSO.ADXRibbons.msrOutlookTask)));
this.myInspectorRibbon.IdMso = "TabReadMessage";
this.myInspectorRibbon.Controls.Add(this.adxRibbonGroup1);
..
this.adxRibbonGroup1.InsertBeforeIdMso = "GroupMessageOptions";


This code shows the Ribbon Tab in the "GroupMessageOptions" of "TabReadMessage" of "msrOutlookMailRead". But it is invisible in all other inspectors.
Is there a way to use the same RibbonGroup for all inspectors, or do I have to create a separate RibbonGroup for each inspector so I am able to give them a custom position.

Regards, Gerhard
Posted 02 Sep, 2011 03:34:29 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gerhard,

It looks like there is no "GroupMessageOptions" tab in other inspectors. Am I right?

Anyway, the Office Ribbon UI components section of the online documentation states:

Still, we recommend turning on the Ribbon XML validation mechanism through the UI of the host application of your add-in; you need to look for a checkbox named "Show add-in user interface errors".


Do you get any UI error message boxes?
.NET, Extended MAPI, Windows Phone & RT
Posted 02 Sep, 2011 03:38:16 Top
Gerhard Grossberger




Posts: 14
Joined: 2011-08-10
Found the checkbox, got an error :oops:
Now Iīm going to try to change the InsertBeforeIdMso etc. in the OnRibbonBeforeLoad event, according to my current inspector.

For further users: hereīs how to find the checkbox.
http://msdn.microsoft.com/en-us/library/bb608619.aspx ;)
Posted 02 Sep, 2011 04:03:10 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gerhard,

Good news! Thank you for letting me know and good luck with your add-in project!
.NET, Extended MAPI, Windows Phone & RT
Posted 02 Sep, 2011 05:15:44 Top
Gerhard Grossberger




Posts: 14
Joined: 2011-08-10
Ok, worked great. Here is the code.
Any suggestions or improvements?

void AddinModule_OnRibbonBeforeLoad(object sender, ADXRibbonBeforeLoadEventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(e.Xml);
XmlNode tabNode = doc.GetElementsByTagName("tab")[0];
XmlNode groupNode = doc.GetElementsByTagName("group")[0];
log.Debug("found tabnode: " + tabNode.InnerXml);
XmlAttribute attrIdMso = doc.CreateAttribute("idMso");
XmlAttribute attrBeforeIdMso = doc.CreateAttribute("insertBeforeMso");

if(e.RibbonId.Equals("Microsoft.Outlook.Mail.Read")) {
//Create a new attribute.
attrIdMso.Value = "TabReadMessage";
attrBeforeIdMso.Value = "GroupMessageOptions";

}
else if(e.RibbonId.Equals("Microsoft.Outlook.Contact")) {
//Create a new attribute.
attrIdMso.Value = "TabContact";
attrBeforeIdMso.Value = "GroupContactOptions";
}
else if (e.RibbonId.Equals("Microsoft.Outlook.Appointment"))
{
//Create a new attribute.
attrIdMso.Value = "TabAppointment";
attrBeforeIdMso.Value = "GroupAppointmentOptions";
}
else if (e.RibbonId.Equals("Microsoft.Outlook.Task"))
{
//Create a new attribute.
attrIdMso.Value = "TabTask";
attrBeforeIdMso.Value = "GroupTaskOptions";
}
if (!String.IsNullOrEmpty(attrIdMso.Value))
{
tabNode.Attributes.Append(attrIdMso);
tabNode.Attributes.RemoveNamedItem("id");
groupNode.Attributes.Append(attrBeforeIdMso);
e.Xml = doc.InnerXml.ToString();
}

}
Posted 02 Sep, 2011 06:58:06 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gerhard,

Do you get any errors or exceptions now? Does it work as expected?
.NET, Extended MAPI, Windows Phone & RT
Posted 02 Sep, 2011 07:08:12 Top
Gerhard Grossberger




Posts: 14
Joined: 2011-08-10
Display is fine, added some try/catch.
Letīs see how this works. Iīll keep you posted!
Posted 02 Sep, 2011 07:59:20 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gerhard,

Could you please let me know whether it works correctly?
.NET, Extended MAPI, Windows Phone & RT
Posted 05 Sep, 2011 04:35:03 Top