VSTO add built-in function to custom ribbon/group - excel

I've search for this and only been able to find the reverse (i.e. add a custom function to an existing ribbon tab/group).
We have a custom ribbon that we want to add some built-in functions to, e.g. we have a few custom number format buttons and beside those, I want to add the regular built-in increase/decrease decimal places buttons so that user doesn't have to return to the Home tab to change decimal places.
How do I add these built-in buttons to my custom tab/group?
I'm on VS 2017, and so far, my method has been using the visual designer to add controls and then clicking through the 'view code' option to code the functionality.

You can't add a built-in control in the Ribbon Designer. Best you can do is to call the Excel functionality you want to use from within the event handler for your custom button.
If you export the Ribbon to XML you can use native Office controls in the Ribbon XML definition by assigning the Control ID value to a control's idMso attribute. Note that the control type must be the same type (you can't use a dropdown instead of a toggle button, for example).
Here's minimal Ribbon XML that shows the elements for the two buttons you ask about:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab idMso="TabAddIns">
<group id="MyGroup"
label="My Group">
<button idMso ="DecimalsIncrease"/>
<button idMso ="DecimalsDecrease"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Depending on the version of Office you're targeting, you can download files of control IDs for the various Office applications. The download is an exe file that unzips to 30+ Excel files listing all (well, most of) the Control IDs. Here are the links to downloads for the current versions of Office:
Office 2010
Office 2013
Office 2016
Office 2007

Related

Is there a catalog of Excel RibbonX editor XML code for the existing menus?

I'm working in the Office RibbonX Editor and I'm trying to reuse the show|hide gridlines from the view tab on my custom tab. I can't find how to duplicate that in my xml. Any idea's on either how to do that, or where I can find the code used in the view ribbon so I can duplicate that.
This is amazing. Found this site with all the code to replicate and Mso ribbon code from any windows tab and use it in your own custom tab.
Hope this helps others building their own custom ribbons in excel!
Here is what I needed to recreate the show|hide gridlines in the Office Ribbonx Editor:
<box id="SH2" boxStyle="horizontal">
<checkBox idMso="GridlinesExcel" />
<box/>
Cheers
https://www.rondebruin.nl/win/s2/win016.htm
Scroll to the bottom of his page and you'll see links to the following:
Download example files?
But how do you know the RibbonX to duplicate the groups in the Ribbon, in the downloads below you can find the RibbonX to hide the built-in groups and to duplicate them so you have full control to change them the way you want.
Download this file from the Microsoft site: Office 2010: Office Fluent User Interface Control Identifiers
Download this file from the Microsoft site: Office 2013: Office Fluent User Interface Control Identifiers
Download this file from the Microsoft site: Office 2016: Office Fluent User Interface Control Identifiers
See also github : https://github.com/OfficeDev/office-fluent-ui-command-identifiers
Excel 365 idMso's (9-July-2020), in the example files I duplicate every group in the Ribbon.
Note: Will add the Draw tab soon
Download Excel 365 example files

Add custom button group to Home ribbon in outlook - VSTO project

I am brand new to VSTO development.I am using visual studio 2017 community edition.I need to show two buttons as a group in the Home ribbon of outlook.I tried with Ribbon control but it shows as a new tab.I want to show the buttons as a group in the Home ribbon itself
Your controls displayed in the new tab because you specified your own id of the tab. To display your group inside existing tab you need to specify id of this tab. id attribute in this case called idMso. For main explorer tab the idMso is TabHome. Your ribbon.xml may look like ...
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="SampleGroup" label="Sample Group">
<button id="Button" label="Sample Button" size="large" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
If you still puzzle yourself, the great way to start for customization of Office Ribbon XML is to read 3 parts of Customizing the 2007 Office Fluent Ribbon for Developers.

How to bind outlook add-in dropdown?

I want to bind a dropdown which is in ribbon.xml file like below, I am not sure how to add items in dropdown. I tried with onAaction event but it is not even firing. any idea how I can proceed with this?
<group id="Family" label="Family Group">
<dropDown id="drpFamily" label="Family" showImage="false" onAction="BindDropdown" />
</group>
All Fluent UI (aka Ribbon UI) controls are described in depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
Also you may find the Extending the User Interface in Outlook 2010 article helpful.
See How to dynamically add items in Ribbon dropdown and Adding items to RibbonDropDown at runtime for more information.

Excel Ribbon XML how to do a control like the Excel "Pivot Table" control

I would like to create a Control like the Pivot-Table in an Add-In XML ribbon.
It's like a clickable button at the top and a dropdown Label opening a menu.
Using the VSTO ribbon designer I am not able to reproduce it.
In fact what I need is the XML for this control.
Any idea ?
You're seeing a splitButton control, which needs to have exactly two children:
a button or toggleButton, and
a menu.
In this case the splitButton has an image set (the pivot table picture) and a child button (with the label 'PivotTable'). The menu then has two children, the two buttons below called PivotTable and PivotChart.
An xml fragment might look like this:
<splitButton id='split' size='large'>
<button id='splitButton' label='SplitButton' image='M' />
<menu id='splitMenu' >
<button id='splitMenuButton1' label='SplitMenuButton1' />
<button id='splitMenuButton2' label='SplitMenuButton2' />
</menu>
</splitButton>
giving me this in Excel:

Need to add button in Outlook Ribbon Search Tab

I have a task to add a button (Export) in Outlook Search tab, after instant search or advanced search i have to grab the result and export to csv file by clicking export button.
I am using VSTO with visual studio 2010 and office 2010.
Any suggestions will be very helpful.
At first, you need to place a button on the right place.
In your xml that will be returned to outlook, specify the right insertBeforeMso code to make sure your button is where you want it. Also find the right idMso for the tab you putting it to.
Here is an example of putting a button on main ribbon of email message window.
<?xml version="1.0" encoding="utf-8" ?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
<ribbon>
<tabs>
<tab idMso="TabNewMailMessage">
<group id="Your ribbon group ID" label="Your button group Label" insertBeforeMso="GroupClipboard">
<button id="Your button ID" label="Your button label" getImage="icon callback" size="large" onAction="click callback" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

Resources