For a customer we were asked to create a split-button with a drop-down menu in an office ribbon. Documented here is how we did this: Result: The Ribbon XML: <?xml version="1.0" encoding="utf-8" ?> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad"> <ribbon> <tabs> <tab id="TabTEST" label="Test 123" visible="true"> <group id="MyGroup" label="My Group" visible="true"> <box id="Box0" boxStyle="horizontal"> <labelControl id="Label0" label="Click or drop down to select: " /> <splitButton id="SplitButton0" size="normal"> <button id="Button0" label="Action" onAction="RibbonControlButtonAction" showImage="false" /> <menu id="Menu0"> <toggleButton id="Option1" label="Option one for action" onAction="RibbonControlToggleButtonAction" getPressed="GetIsPressed"/> <toggleButton id="Option2" label="Option two for action" onAction="RibbonControlToggleButtonAction" getPressed="GetIsPressed"/> </menu> </splitButton> </box> </group> </tab> </tabs> </ribbon> </customUI> The code behind: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Core; using System.Reflection; using System.IO; using System.Runtime.InteropServices; namespace WordAddInDropDownMenu { [ComVisible(true)] public class Ribbon1 : IRibbonExtensibility { public string GetCustomUI(string ribbonID) { return GetResourceText("WordAddInDropDownMenu.Ribbon1.xml"); { return control.Id.Equals(_lastPressed); } private IRibbonUI _ribbon; } }
|
Home >