Chapter 5. Callbacks: The Key to Adding Functionality to Your Custom UI

If you've worked through the earlier chapters, you already know some of the basics relating to Ribbon customization, such as XML structure, and you've had an introduction to VBA. This chapter introduces you to callbacks — the code that makes your customization work.

Without callbacks, your UI may look beautiful, but that's all it will be: just a pretty Ribbon — that is, of course, unless you are drawing from built-in controls, as they don't require custom callbacks. However, for custom controls, looks just aren't enough. What really matters is that your UI adds value for the user. In this chapter you learn the basics about how callbacks provide the functionality required for custom controls to work.

In the following pages you learn a combination of XML and VBA, as you will need to specify a callback in your XML code and then write VBA code to match and handle that callback. As you are preparing to work through the examples, we encourage you to download the companion files. The source code and files for this chapter can be found on the book's web site at

Callbacks: What They Are and Why You Need Them

Callbacks are subprocedures and functions used by your custom UI to make your customization work. A callback simply represents the movement of the instruction given. For example, when you set the onAction attribute for a button and load the UI, once the button is clicked it generates a callback ...

Get RibbonX: Customizing the Office 2007 Ribbon now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.