How do you customize a tab in the Ribbon?
You can arrange, add or hide groups or commands as needed in the tabs of the Ribbon.
Arrange
-
Use the buttons Move Up, Move Down and Move to Group.
-
Use the drag-and-drop to move an element inside or outside a node element, and into any level.
Show or hide
-
To hide or display all the groups and elements of a tab, use the Show / Hide all Elements.
-
To hide or display all the sub-elements of a group or an element, select the group or element, then right click and use the commands Show all Elements of and Hide all Elements of.
-
Select or deselect the checkboxes in the tree view.
Add
You can create new tabs.
-
new groups
-
inside a group you have created, you can create the following types of elements: menu, separator, button, split button, or toggle button.
How do you do it?
To create or delete new tabs, use the New Tab button (or the tab with the + icon) and the Delete Tab button. You can enter a name for a new tab and specify where to position it, before or after an existing tab (amongst the tabs that are natively delivered with Microsoft Excel).
To create or delete the groups or elements, use the New Group, New Sub-Element, Delete buttons or the same commands that you access from the context menu in the tree view of the tab.
What elements can you create?
- Menu: label, size of the icon, icon.
- Separator: no properties.
- Button: identifier, label, macro, image size, image.
- Split button: identifier, label, macro, image size, image.
- Toggle button: identifier, label, macro (for the action), macro for the state of the button (pressed or not), image size, image.
What are the possible properties of the elements you create?
- Label: enter the name of the element as it will appear on the interface.
- Image: choose the image that you want to be displayed next to the label.
The images are stored within the profile xml.
- Image size: choose the size Normal or Large, depending on the type of element and available user interface space. If you are creating a group, choose Large. If you are creating another element, choose Normal.
- Get Button State: macro that sets the state of the toggle button, pressed or not.
- Macro: see below the Macro section.
- Display ID: see below the ID section.
IDs
To display an ID, select the option Display ID.
To modify an ID, select the option, then modify it in the row ID.
Here are the syntax rules for an ID : must be unique, must not contain colons, must start with either a letter or underscore (_) and may contain only letters, digits, underscores (_), hyphens (-), and periods (.).
Macros
For buttons, split buttons, and toggle buttons, you call VBA macros to perform the actions.
-
In an .xlam file that you need to enable as an add-in to Microsoft Excel. In this case, in the Macro area, enter the name of the file, followed by ! and then by the name of the macro that you want to call. For example: functions.xlam!opendocument
-
Directly in the current workbook. In this case, you simply enter the name of the macro in the Macro area. For example: opendocument
Even if you do not use it, the first parameter must be the control of type IRibbonControl.
Example of macro for a button action:
Example of macro for the state of a toggle button: