Add the Lock Icon to a Custom Microsoft Access Ribbon
Question details
Add the built-in lock icon to a button on a custom Microsoft Access Ribbon using Ribbon XML.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A custom Access Ribbon needs a button that displays the built-in lock image.
- Observed behavior
- The desired button displays the lock icon through an imageMso reference and can call a VBA procedure when clicked.
Open the Access database containing the custom Ribbon and identify its Ribbon XML and intended button callback. You will need permission to edit the database and its VBA code.
Add imageMso="Lock" to the Ribbon button
Use this method to display the built-in lock image and load the customized Ribbon in Access.
In your Ribbon XML, add a button inside a custom group, for example: <button id="buttonName" imageMso="Lock" onAction="procedureName" label="My Button" showImage="true"/>. Check that the attribute names, quotation marks, and spacing are correct.
Create or open the USysRibbons table in the database. Store the complete Ribbon XML in its RibbonXml field and give the entry a name in the RibbonName field. If creating the table, add an AutoNumber ID field, a Short Text RibbonName field, and a Long Text RibbonXml field.
Close and reopen the database so Access reads USysRibbons. Go to File > Options > Current Database, find Ribbon and Toolbar Options, and select the entry under Ribbon Name. Close and reopen the database again to apply it.
In the VBA editor, add a public procedure named procedureName in a standard module with the signature Public Sub procedureName(control As IRibbonControl). Add the action you want the button to perform, and allow the database code to run if prompted.
If the Ribbon or button does not appear, go to File > Options > Client Settings and enable Show add-in user interface errors under General. Reopen the database and use any reported errors to check the XML and callback name.

Use WPS Office for everyday document editing
WPS Office is a free, lightweight alternative for working with documents, spreadsheets, and presentations. Its familiar interface and support for common Microsoft Office formats make it easy to move existing files into your workflow. It does not customize Microsoft Access Ribbons or replace Access databases.

Frequently Asked Questions
What attribute displays the lock icon on an Access Ribbon button?
Add imageMso="Lock" to the button element in your Ribbon XML. You can also include showImage="true" to explicitly show the image.
Where does Access store custom Ribbon XML?
A database can store custom Ribbon definitions in the USysRibbons table. Put the Ribbon name in RibbonName and the complete XML in RibbonXml, then select it under File > Options > Current Database.
Why does the button show a lock but not perform an action?
The imageMso attribute only controls the image. Set onAction to the name of a public VBA callback in a standard module and implement the desired action in that procedure.
How can I find errors in my custom Ribbon XML?
Go to File > Options > Client Settings and enable Show add-in user interface errors under General. Reopen the database, then check any reported XML syntax or callback errors.




