Color scheme: Light
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Take over a ribbon written by hand

How to: Take over a ribbon written by hand

Open a ribbon whose RibbonXML was written by hand in the USysRibbons table in the ribbon designer, so that you can edit it there from now on.

Requires WKL Forms Object Library 1.58 or later.

Solution overview

When the database has rows in USysRibbons that the ribbon model doesn't own, the Ribbons page of the ribbon designer shows the Existing ribbons card with their names. Read in reads the RibbonXML of each row into the model: tabs, groups, buttons, toggle buttons, menus, split buttons, separators, built-in commands (idMso), and custom File view tabs with their tasks. Each custom control becomes a command named after its id; a control with idMso becomes a command with the action Built-in command (idMso), shared by every place that names it.

Nothing is written until you click OK or Apply in the designer: saving replaces the taken-over rows in USysRibbons with the generated XML and writes the callback module. Cancel leaves the database as it was. When the database property CustomRibbonID names a taken-over ribbon and the model doesn't have an application ribbon yet, that ribbon becomes the application ribbon.

Implementation

  1. Open the ribbon designer (the WKL Ribbon Designer add-in entry, or WklRibbon.ShowDesigner from VBA).
  2. On the Ribbons page, in the Existing ribbons card, choose Read in.
  3. Read the list below the button: each line names a part that was left out or simplified.
  4. Fix what the list names (see Remarks), check the Check page, and then choose OK.
  5. Close the database and open it again; Access applies ribbons when the database opens.

An onAction callback must become a function without arguments. Before:

<button id="btnCustomers" label="Customers" onAction="OnCustomers"/>
Public Sub OnCustomers(control As IRibbonControl)
    DoCmd.OpenForm "frmCustomers"
End Sub

After the takeover, on the Commands page, give the command btnCustomers the action Open form with frmCustomers, or the action Call VBA function with:

Public Function OpenCustomers() As Boolean
    DoCmd.OpenForm "frmCustomers"
    OpenCustomers = True
End Function

An onAction written as an expression (onAction="=OpenCustomers()") is taken over as the action Call VBA function OpenCustomers, without a note.

Remarks

In the XMLAfter the takeover
onAction that names a procedureThe command has no action; a note names the procedure.
getLabel, getVisible, getEnabled, getImage, and other get… callbacksLeft out with a note; the static value (for example, label) stays. For dynamic values, use the command's condition and the runtime object.
onLoad, loadImageLeft out with a note; the generated module has its own.
comboBox, editBox, dropDown, gallery, checkBox, dynamicMenu, labelControl, dialogBoxLauncherLeft out with a note.
box, buttonGroupDissolved: their controls stay in the group.
splitButton inside a menuBecomes a menu with the command of its button.
Built-in tab or group (idMso on tab or group)Left out with a note.
qat, contextualTabs, commands, contextMenusLeft out with a note.
visible="false" on a custom elementLeft out with a note.
Built-in File view entry with visible="false"Kept: listed as hidden in the File view.
image that names a picture whose name isn't validLeft out with a note.
id that isn't a valid name or is already in useMade valid and unique (tab.Start becomes tab_Start, and a second btnCustomers becomes btnCustomers_2).

Your own callback procedures stay in your modules, but the generated ribbon no longer calls them. Remove them once the commands have their actions.

en/wiki/msaccess/comctl/how-to/take-over-a-ribbon-written-by-hand.txt · Last modified: by Wolfgang van der Stille