This documentation is archived and is not being maintained.

Ribbon UI Customization in Access 2007

Office 2007

RibbonX customizations in Microsoft Office Access 2007 share some of the same options as the other Microsoft Office applications but with some important differences. Just as with the other Office 2007 applications, you customize the Access Ribbon UI using XML markup. And like the other applications, you can use external files containing XML markup, or COM add-ins to integrate ribbon customizations into your application. However, unlike the other Office applications, because Access database files are binary and cannot be opened as the new Office Open XML Formats files, you can not customize the Access Ribbon UI by adding parts to the database file.

Aa434076.vs_note(en-us,office.12).gif  Note
For more information on the Ribbon UI in other Office applications, see Overview of the Ribbon User Interface
Access does provide 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. You can also specify a custom UI for the application as a whole or for specific forms and reports.

All Access UI customizations have one thing in common. The Ribbons they represent are only made available to the application by calling the only Ribbon-specific Access VBA object member, the LoadCustomUI method. The signature for this method is:
expression.LoadCustomUI(CustomUIName As String, CustomUIXML As String)
where expression returns an Application object and CustomUIName is the name of the Custom Ribbon ID to be associated with this markup, and CustomUIXML contains the XML customization markup. 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. Once 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.

To implement a custom UI so that it is available when the application starts, do the following:
  1. Follow the process described previously to make the customized Ribbons available to the application.
  2. Close and then restart the application.
  3. Click the Microsoft Office Button (File menu) and then clickAccess Options.
  4. Click the Startup option and then, in the Application Options section, click the Custom Ribbon ID list and select a ribbon.
  5. Now close and restart the application. The UI you selected is displayed.

To assign a custom UI to a form or report, do the following:
  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
    Custom Ribbon ID
    list and then select a ribbon.
  5. Save, close, and then reopen the form or report. The Ribbon UI you selected is displayed.
    Aa434076.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 or report’s Ribbon UI are in addition to the existing tabs.

The UI in Access 2007 offers users a flexible way to work with database solutions. 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. Because the XML markup is contained in a single file, modifying the interface as requirements change is much simpler. You can also improve user productivity by putting the commands where users can find them easily. Finally, the Ribbon adds consistency across your applications, which reduces the time users spend learning each application.

Aa434076.vs_note(en-us,office.12).gif  Note
For detailed information on customizing the Ribbon UI in Access, search Access help for How to: topics.