Creating custom Ribbons - part 3

We are now at the most exciting part of the ribbons programming, which is to change the controls dynamically. We can hide, disable, insert images, change names and more. This is done through the attributes gets

Let’s see the following list of gets attributes from the button control


Scenario 1 - Imagine that an application is accessed by multiple users and that each user has a different kind of access allowed. For example, John cannot have access to the form of customers, but Carlos can access it. For this situation we can set the button on the ribbon that opens the Customers form, so that it becomes visible only to Carlos. Configure this button with the attribute getVisible, calling a specific function. This function will give to the getVisible the value true or false, determining the state of the button (visible or invisible) according to the User logged.

An example of the button that opens the Customers form:

id = "btCustomers"
label = "Customers"
getVisible = "fncGetVisible"
onAction = "fncOnAction"

Now I Will show you a very simple example of the function fncGetVisible:

Public Sub fncGetVisible(control As IRibbonControl, ByRef visible)

Select Case 
   Case "btCustomers"
      if user = "john" then
         visible = false
      elseif user ="carlos" then
         visible = true
      end if
End Select

End Sub

Note that if the User logged in is John, the visible argument assumes the value false, and if the user logged in is Carlos, the argument assumes the value true.

Assuming then that the user logged in is John; the function will give for the attribute getVisible the value false, making the button invisible

id = "btCustomers"
label = "Customers"
getVisible = "false"
onAction = "fncOnAction"

Scenario 2 - Suppose an application is being designed for both English and Portuguese languages, and the buttons names on the ribbon must be loaded depending on the selected language. In this scenario we will use getLabel.

An example of the button with the attribute getLabel:

id = "btCustomers"
getVisible = "fncGetVisible"
getLabel = "fncGetLabel"
onAction = "fncOnAction"

The function fncGetLabel :

Public Sub fncGetLabel(control As IRibbonControl, ByRef label)

Select Case 
   Case "btCustomers"
      if language = "portuguese" then
         label = "Clientes"
      elseif language = "english" then
         label = "Customers"
      end if
End Select

End Sub

If the chosen language is Portuguese, the function will give the getlabel the value “Clientes”

id = "btCustomers"
getVisible = "fncGetVisible"
getLabel = "Clientes"
onAction = "fncOnAction"

Scenario 3 - It is very common to also upload the buttons with our own images. This will be talked about in the fourth class, where I teach more than one way of loading them, including PNG images.

When the ribbon is loaded for the first time are evaluated each of the gets used and their values are loaded, as the functions of each attribute.

How can you get the get's to be revalidated after the ribbon is loaded?

The ribbon has two methods called Invalidate and InvalidateControl. The Invalidate revalidates all the controls of a ribbon, while the method InvalidateControl revalidates the control that you specify

Now, pretend that you want, in a given event, revalidate the state of two buttons (customers and suppliers) of a loaded ribbon. You just need to enter the id attribute of the control to be revalidated.

objRibbon.invalidateControl ("btCustomers")
objRibbon.invalidateControl ("btSuppliers")

To access the methods Invalidate and InvalidateControl we must do some configurations. The first one is to refer to the class "Microsoft Office 1(2/4/5/6).0 Object Library" that I have taught at the second video class.

The second configuration is to put the Ribbon in the cache, by a variable. See the code below, which must be created in a global mode

Option Compare Database
Public objRibbon As IRibbonUI

Public Sub fncRibbon(ribbon As IRibbonUI)
On Error Resume Next
'objRibbon will be used by us to realize changes
'in the ribbon at runtime
Set objRibbon = ribbon
End Sub

To complete it you need to put the ribbon in the variable objRibbon, called by the function fncRibbon. This is done by the onLoad attribute of the tag customUI. See a part of the xml:

<customUI xmlns="" 

See the methods available by the variable objRibbon:

Usando Access


Video class

In this video class you will have a brief presentation of the attributes gets. You will learn, in detail, how to set up the ribbons for the dynamic exchange of languages. You will also learn how to hide / disable the controls of the ribbon, depending on the user logged in.





Article and Video 1

Brief presentation of MontaRibbons
Structural concept of the XML used
How to disable all the upper ribbon of the Access
Using images from the Office’s gallery
Using internal controls of the Office
Customizing the quick toolbar
Customizing the Office Button
How to create a custom ribbon

Article and Video 2

Setting the control splitButton
Setting the control menu
Differences between the controls splitButton and menu
Exporting the ribbons for your applications
How to give functionality to the buttons on the ribbon

Article and Video 4

Using external images (GIF, JPEG e PNG)

Article and Video 5


Images (GIF, JPEG, PNG e ICO) taken from the attachment type field 

Article 6


Article 7

Combobox and Dropdown, in practice


All the details about how to purchase



10 comment(s)

Ribbon Hacker   5/26/2013 6:36:55 AM

thanks for this tutorial! I'm developing a PowerPoint add-in to help me produce synchronized TTS audio narration. Never before programmed PowerPoint VBA, much less its Ribbon, but I'm finding just enough help on the net to help me through the exercise. Yours is the only one I've see so far that showed how to get our hands on the IRibbon handle itself. Excellent! good to know someone out there has actually gone into Ribbon Programming as deep as I have. I always have the impression that, although MS Office is the most popular office productivity app out there, but at the same time it's also the least developed in terms of the number of software developers willing to extend it.

Anyway, thanks again, and I'm back to my PP add-in project!

Peter   6/25/2013 9:26:22 AM

I have a DB that uses a custom Login form for users permissions using global variables. How can I set the Ribbon to load after the user clicks Login button so the tabs will be visible/invisible according to user access. I have only one ribbon with multi tabs.

Avelino Sampaio   6/25/2013 9:38:07 AM


See question number 15 of the FAQ

Download the file from this example Maestro my other site (in Portuguese but I believe that you can understand)

Jean Rony Chavannes   10/11/2016 1:19:45 PM

svp pouvez m'envoyer le fichier MontaRibons en format accdb svp

Les   7/19/2019 12:38:14 AM

I'm just about to buy your product and have a question that may influence my decisions somewhat.

Can I replace the whole ribbon at run-time? Can I change rbnMarc to rbnPrincipal without having to restart the database?

Avelino Sampaio   7/19/2019 1:23:22 AM

Hi Les

The solution to your case would be to create a single ribbon, containing the two tabs. A tab with the rbnMarc xml and the other tab with the rbnMain xml.

Any other questions, do not hesitate to ask me.

Les   7/19/2019 3:55:23 AM

Thanks for the prompt reply. My db is for a hospital with a typical dropdown-style menu and on VS2017 I can build a dynamic menu structure at logon depending on the access permissions for the user. I was hoping to be able to do something along these lines in Access.

Is it possible to have a single ribbon, but calculate and load the xml portion as the user connects to the db?

Avelino Sampaio   7/19/2019 4:21:17 AM


Yes, it is perfectly possible to set the ribbon buttons at runtime according to the logged in user.

Les   7/22/2019 5:33:49 PM

Thanks Avelino. I'm particularly interested in the DynamicMenu option. Should I buy, is there a step-through or video presentation on how to use DynamicMenu?

Avelino Sampaio   7/23/2019 8:55:34 AM


In the "help" application has an example with the XML code and the necessary functions.


Send your comment: