How to: Apply a Custom Ribbon to a Form or Report

Access Developer Reference

The Ribbon uses text-based, declarative XML markup that simplifies creating and customizing the Ribbon. With a few lines of XML, you can create just the right interface for the user. Access provides tremendous flexibility in customizing the Ribbon UI. For example, customization markup can be stored in a table, embedded in a VBA procedure, stored in another Access database, or linked to from an Excel worksheet. This topic discusses how to apply customized ribbons when loading a form or report.

Making the Ribbon Customization XML Available

Storing Ribbon Extensibility XML in a Table

One method that you can use to make Ribbon customizations available is to store them in a table. If you store the customizations in a table named USysRibbons, the customizations can be implemented without using macros or VBA code.

USysRibbons is a user-created system table. The table must be created using specific column names in order for the Ribbon customizations to be implemented. The following table describes the settings to use when creating the USysRibbons table.

Column Name Data Type Description
RibbonName Text Contains the name of the custom ribbon to be associated with this customization.
RibbonXML Memo Contains the Ribbon Extensibility XML (RibbonX) that defines the Ribbon customization.

Loading Ribbon Extensibility XML Programmatically

You can use the LoadCustomUI method to load Ribbon customizations programmatically. Typically, to create and make the Ribbon available to the application, you first create a module in the database with a procedure that calls the LoadCustomUI method, passing in the name of the ribbon and the XML customization markup.

The XML markup can come from a Recordset object created from a table, from a source external to the database such as an XML file that you parse into a string, or from XML markup embedded directly inside the procedure. You can make different ribbons using multiple calls to the LoadCustomUI method, passing in different XML markup as long as the name of each ribbon and the id attribute of the tabs that make up the ribbon are unique.

After the procedure is complete, you then create an AutoExec macro that calls the procedure by using the RunCode action. That way, when the application is started, the LoadCustomUI method is automatically executed and all of the custom ribbons are made available to the application.

Assigning Custom Ribbons to Forms or Reports

  1. Follow the process described previously to make the customized Ribbon available to the application.
  2. Open the form or report in Design view.
  3. On the Design tab, click Property Sheet.
  4. On the All tab of the Property window, click the Ribbon Name list and then select a Ribbon.
  5. Save, close, and then reopen the form or report. The Ribbon UI you selected is displayed.
Bb258191.vs_note(en-us,office.12).gif  Note
The tabs displayed in the Ribbon UI are additive. That is, unless you specifically hide the tabs or set the Start from Scratch attribute to True, the tabs displayed in a form's or report's Ribbon UI are in addition to the existing tabs.
Bb258191.vs_note(en-us,office.12).gif  Note
For more information about the Ribbon UI in other Office applications, see Overview of the Ribbon User Interface.