适用于:Access 2013、Office 2013
The ribbon uses text-based, declarative XML markup that simplifies creating and customizing the ribbon. 使用几行 XML,您可以为用户创建适当的界面。 Access 在自定义功能区用户界面方面更好地提供灵活性。
例如,自定义标记可以存储在一个表中,嵌入在 VBA 程序中,存储在另一个 Access 数据库中,或链接到某个 Excel 工作表。 本主题介绍加载窗体或报表时如何应用自定义的功能区。
提供功能区自定义 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.
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.
为窗体或报表指定自定义功能区
- 按照先前描述的过程将自定义的功能区提供给该应用程序使用。
- 在“设计”视图中打开窗体或报表。
- 在“设计”选项卡上,选择“属性表”。
- 在“属性”窗口的“所有”选项卡上,选择“功能区名称”列表,然后选择一个功能区。
- 保存并关闭,然后重新打开窗体或报表。 将显示您选择的功能区 UI。
注意
在功能区 UI 中显示的选项卡具有累加性。 即,除非明确隐藏选项卡或将“从头开始”属性设置为“True”,否则显示在窗体或报表功能区用户界面中的选项卡是对现有选项卡的补充。
注意
有关其他 Office 应用程序中的功能区 UI 的详细信息,请参阅 Office Fluent 功能区概述。