Add a custom Ribbon to a database in Access 2007

Ribbon was introduced in Microsoft Office 2007 as part of its "Fluent User Interface" and has became a well known and quite often used part of graphical user interface of applications (specifically on MS Windows). In MS Access prior the 2007 version the user interface of an database application was implemented by standard GUI elements such as forms, buttons, menus and context menus. The users of MS Office 2007 are used to work with Ribbon and are familiar with its advantages e.g. its shortcut system, we want to provide them with a custom Ribbon interface of Access 2007 database application.
1 answer

Application.LoadCusomUI + xml description

To implement a custom Ribbon element we have to describe it using an XML file defined by the Microsoft CustomUI schema and load it using the Application.LoadCustomUI() procedure.

The root element of the XML file is customUI. Inside of it there is the element ribbon containing all the tabs, buttons etc.

A code snippet for loading of the xml file:

Dim f As Long
Dim strText As String
Dim strOut As String

f = FreeFile
Open "\customUI.xml" For Input As f

Do While Not EOF(f)
Line Input #f, strText
strOut = strOut & strText
Loop

Application.LoadCustomUI "AppRibbon_1", strOut

Sample XML file:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="Tab1" label="Tab1">
<group id="Group" label="Group">
<button id="MyButton1" label="Button1" imageMso="_1"
onAction="doSomeAction"/>
<button id="MyButton2" label="Button2" imageMso="_2"
onAction="doSomeAction2"/>
</group>
<group id="Group2" label="Group2">
<button id="MyButton3" label="Button3" imageMso="_1"
onAction="doSomeAction3"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

Taggings: