How to add a button to a pre-existing tab on ribbon (C#)?
Solution 1
The attribute idMso
is correct, but the id for the tab you want is TabMail
. You can find a packed set of Excel-files containing lists of Office 2010 control IDs on MSDN. Then, as mentioned in a comment to the question, your sample XML may be missing the customUI and ribbon-tags. (Disclaimer: I haven't customized the ribbon in Outlook, only Word, Excel and PowerPoint, but I would guess they work the same?)
Try something like the this:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab idMso="TabMail">
<group id="group1" label="Hazaa!">
<box id="box1" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Solution 2
If you just want a button to appear in an existing ribbon, in Visual Studio, here https://msdn.microsoft.com/en-us/library/bb608628.aspx#Anchor_2
in your case change the OfficeId to TabMail
Solution 3
For people frustrated that none of the other answers seem to be working, go to the properties for the Ribbon itself and set the RibbonType
to Microsoft.Outlook.Explorer
(or whichever context[s] you want to see the control in). It's a crucial step that's easy to overlook.
Then follow the other instructions to set OfficeId
to TabMail
.
Additionally, Office 2016 Fluent Control Identifiers can be found here: https://www.microsoft.com/en-us/download/confirmation.aspx?id=50745
Admin
Updated on June 08, 2022Comments
-
Admin almost 2 years
I've successfully created a new tab and put it next to the pre-existing ones. Then I realized that I'll only have one button on it, so it makes more sense (for now) to put it on the Home tab. Didn't really get that to work though.
I've tried to follow the guides and walk-troughs. I've got me an XML and changed its XML to the following.
<tabs> <!--<tab idMso="TabAddIns">--> <tab idMso="TabHome"> <group id="group1" label="Hazaa!"> <box id="box1" /> </group> </tab> </tabs>
When I run the project I get no changes to the UI, so I guess that either:
- the XML is not read at all,
- the name
TabHome
is wrong (at least for Outlook 2010), - the attribute
idMso
is wrong (at least for Outlook 2010) or - other/combination of any of the mentioned.
What can I do to alter the ribbon? (Outlook 2010/VSTO/VS 2010/.NET 4).
-
Admin over 11 yearsThat was it. Very gotcha-ish, I may add. For future reference - how can I list all the names of all the tabs currently installed/visible/available in the Outlook/Word/Any other ribbonized software? I saw a hint somewhere that I could go to QAT and check them in the tool tips but that's only good for the components inside the tabs. The very tabs themselves show no tool tips...
-
Olle Sjögren over 11 yearsI think there is a reference for it somewhere on msdn, but I can't find it at the moment...
-
Olle Sjögren over 11 yearsBtw, you can mark the question as answered by clicking the checkmark beside the answer, with an upvote if you wish.
-
Admin over 11 yearsYes, I wish. I'm just trying to look up some extra info to put in so that the next poor soul that will runs into this problem won't have to ask a follow-up questions. I'm trying to google for a few of the common tab names but that doesn't give me any link to a list. Someone suggested that I download a file with all the names but it's an EXE and I can't see the point of distributing a text file as an executable so I'm assuming that the tip was wrong or misunderstood, until someone savvy tells me otherwise.
-
Olle Sjögren over 11 yearsOK, I think I found it. The exe mentioned is a zip-file with a bunch of excel-files with the IDs for the different office programs. Updating answer with the link!
-
Admin over 11 yearsNow a question remains - what if I want to refer a tab that isn't a default MS-tab on the ribbon? E.g. CRM Dynamics adds one and how I'm supposed to get its name?!
-
Olle Sjögren over 11 yearsMaybe this Q+A can help you with IDs for the thirdparty tab? Leave a comment here if you get it to work...
-
HK1 over 11 yearsNone of the Excel files with the Office 2010 control IDs show TabMail as a valid idMso. Or did I miss it?
-
Olle Sjögren over 11 yearsIt's in OutlookExplorerControls.xlsx... :)
-
Yonatan almost 3 yearsthe link no longer works here is a good resource github.com/OfficeDev/office-fluent-ui-command-identifiers