Since Excel 2007, the Office Ribbon has become the preferred way of adding your own commands to Excel's user interface. Programatically, the ribbon is much harder work than the old method of adding your own menus and toolbars to the Excel UI. However, the interface is much richer and more powerful than the menu/toolbar UI offered by Excel 2003 and earlier versions, and you can create a much more efficient and intuitive interface for your users.
You can generate all the code required for a ribbon by checking the option Add a group to the ribbon in the XLL+ AppWizard.
Checking this option will cause a number of changes to your project. The most important changes are as follows:
An XML file, named [YourAddin].RibbonX
is created and added to your project.
When the project is built, this file will be embedded in the XLL file as a resource.
A virtual function, OnRibbonEvent
, is added to your application class.
This is the place to put any code that responds to user's ribbon actions or that alters
the ribbon's appearance and content at run-time.
For a full list of the ribbon-related changes made to a project by the AppWizard see Adding ribbon support to a project.
The only way to add items to the Office Ribbon is through a COM add-in.
It cannot be done through a standard XLL add-in.
The toolkit therefore includes a COM add-in, XlpRibbonServer.dll
, which manages
all the COM extensibility requirements, and routes ribbon events via the XLL, where they
can be handled by the OnRibbonEvent() method.
Like other COM modules, the XLL+ Ribbon Manager must be registered before it can be used. On a development machine, the module is registered when the toolkit is installed. For instructions on deploying to users' machines, see the reference section Deploying add-ins that use the Office Ribbon.