启动 Access 时应用自定义功能区

适用于: Access 2013 | Office 2013

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. 例如,自定义标记可以存储在一个表中,嵌入在 VBA 程序中,存储在另一个 Access 数据库中,或链接到某个 Excel 工作表。 This topic describes how to apply customized ribbons when opening a database.

提供功能区自定义 XML

在表中存储功能区可扩展性 XML

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 是用户创建的系统表。 必须使用特定的列名创建表才能实现功能区自定义。

下表列出创建 USysRibbons 表时要使用的设置。

列名称

数据类型

说明

RibbonName

Text

Contains the name of the custom ribbon to be associated with this customization.

RibbonXML

备注

包含定义功能区自定义的功能区扩展性 XML (RibbonX)。

以编程的方式加载功能区扩展性 XML

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.

完成此程序后,使用 RunCode 操作创建调用该程序的 AutoExec 宏。 这样一来,启动应用程序时,LoadCustomUI 方法会自动执行,所有自定义功能区将提供给应用程序。

Access 启动时,应用自定义功能区

To apply a custom UI so that it is available when the application starts, use the following procedure:

  1. Follow the process described previously to make the customized ribbons available to the application.

  2. Close and then restart the application.

  3. 选择“ Microsoft Office 按钮O12FileMenuButton_ZA10077102 ,然后选择 ”访问选项”。

  4. 选择“当前数据库”选项,然后在“功能区和工具栏选项”部分,选择“功能区名称”列表,然后选择一个功能区。

  5. Now close and restart the application. The UI you selected is displayed.

备注

有关其他 Office 应用程序中的功能区 UI 的详细信息,请参阅 Office Fluent 功能区概述