Adding Your Macros to the Ribbon

To add a macro to a tab, you need to declare the macro as a Ribbon control, and then create a button definition in customUI.xml that includes an onAction command. As you might know from creating custom toolbars or menus through VBA in previous Microsoft Office versions, you use onAction to identify the macro that runs when the specified button is clicked.

Examine, for example, the sample file Generate GUID.docm used in Chapter 22. This file contains one macro and uses a single Ribbon tab with a single button for running that macro.

The following image shows the contents of customUI.xml for this file.

Adding Your Macros to the Ribbon

Take note of the ...

Get Advanced Microsoft® Office Documents 2007 Edition Inside Out now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.