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


Guest


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


Guest


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.
Posted 02 Sep, 2011 01:28:38 Top
Gerhard Grossberger


Guest


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


Guest


Hi Gerhard,

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

Anyway, the http://www.add-in-express.com/docs/net-ribbon-components.php 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?
Posted 02 Sep, 2011 03:38:16 Top
Gerhard Grossberger


Guest


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


Guest


Hi Gerhard,

Good news! Thank you for letting me know and good luck with your add-in project!
Posted 02 Sep, 2011 05:15:44 Top
Gerhard Grossberger


Guest


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


Guest


Hi Gerhard,

Do you get any errors or exceptions now? Does it work as expected?
Posted 02 Sep, 2011 07:08:12 Top
Gerhard Grossberger


Guest


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


Guest


Hi Gerhard,

Could you please let me know whether it works correctly?
Posted 05 Sep, 2011 04:35:03 Top