Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » Navigation and commands » WklRibbon » Give an application its own ribbon

Give an application its own ribbon

In this tutorial, you use the ribbon designer to give a small database its own ribbon: a tab with two commands, a command that appears only during development, and a File view with a task. It takes about fifteen minutes and needs only one VBA function.

Prerequisites

  • Microsoft 365 Access, 32-bit or 64-bit, with the WKL Forms Object Library 1.49 or later installed and registered for the current Windows user (How to: Install the released package).
  • The WKL Extensions add-in installed, so that Database Tools › Add-Ins offers WKL Ribbon Designer: tools\install-addin.ps1 in the release package (1.55 or later) installs addin\WklExtensions.accda for the current user. Without the add-in, you can also open the designer from the Immediate window: CreateObject("WklForms.Ribbon").ShowDesigner.
  • A new database in a trusted location with a form frmCustomers and a report rptCustomers.

Steps

1. Add a function for the export

Create a standard module with this code:

Public Function ExportCustomers() As Boolean
    On Error GoTo Failed
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "tblCustomers", CurrentProject.Path & "\Customers.xlsx", True
    ExportCustomers = True
    Exit Function
Failed:
    MsgBox "The export failed: " & Err.Description, vbExclamation
End Function

A function that a ribbon calls handles its own errors; an unhandled error would show the VBA error dialog box.

2. Open the designer

Choose Database Tools › Add-Ins › WKL Ribbon Designer. The designer opens on the Commands page.

3. Create the commands

Click New three times and fill in:

NameCaptionOffice imageActionTarget
cmdCustomersCustomersFileOpenOpen formfrmCustomers
cmdPrintCustomer ListFilePrintPreviewOpen report (print preview)rptCustomers
cmdExportTo ExcelExportExcelCall VBA functionExportCustomers

For cmdExport, type DEV under Visible when › Profiles: the command appears only while the database is linked with the Linked Tables Manager's DEV profile (or after WklRibbonObject().Profile = "DEV").

4. Build the ribbon

On the Ribbons page, click Ribbon; the first ribbon is the application ribbon. Select it, click Tab, and name the tab tabHome with the caption Home. Click Group and give it the caption Customers. Click Entry three times and choose the three commands under Command. Set the Size of cmdCustomers to Large. The preview on the right shows the tab.

5. Add the File view

On the File view page, click Tab (caption Modules), Task group, Category, and Task, and choose cmdCustomers as the task's command. Under Hide, type TabPrint to hide the built-in Access Print tab.

6. Save and reopen the database

The Check page reports ready to save. Click OK. Close the database and open it again: the Home tab shows the Customers group.

Expected result

The database has its own tab with three commands, with the export available only during development, and a File view with the task Customers. Clicking Customers opens the form, and clicking Customer List opens the report in print preview. The model is stored in USysWklRibbon and comes back in the designer the next time you open it.

Next steps

en/wiki/msaccess/comctl/navigation-and-commands/ribbon/tutorial.txt · Last modified: by Wolfgang van der Stille