How to Hide and Unhide Microsoft Access Toolbar and Ribbon using VBA code


The MS Access menu and the toolbar is have been replaced with the Ribbon, which is part of the Microsoft Office Fluent user interface, this utility provides easy to use interface to the user

Here is an article explained to guide you to customize this ribbon through the code. Basically, this article tells you that how to hide and unhide the MS Access “Ribbon”.

There is the example to execute this task. Create a form with buttons to Show, Hide and Toggle the ribbon as shown in Fig: - 1.1

When the user will click onto the “Show” button the “Ribbon” will appear at the top.

How to Hide and Unhide Ribbon and Toolbar using VBA Fig-1.1

Fig-1.1

When the user click on “Hide” button then “Ribbon” and toolbar will get hide from the top of the form. As shown in Fig:- 1.2

How to Hide and Unhide Ribbon and Toolbar using VBA Fig-1.2

Fig-1.2

Toggle button is used here to hide and unhide the toolbar. If toolbar is in hide state then click on “Toggle“ button and the toolbar will appear and if the “Ribbon and Toolbar” is shown already then after clicking “Toggle” it will disappear as shown in Fig:-1.3

How to Hide and Unhide Ribbon and Toolbar using VBA Fig-1.3

Fig-1.3

Here is the VBA Code provided for Hide and Unhide the ribbon and toolbar :-

'-----------------Code for click event of "Hide" button-----------------

Option Compare Database
Private Sub Hide_Click()
DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Sub

'-----------------Code for click event of "Show" button-----------------

Private Sub Show_Click()
DoCmd.ShowToolbar "Ribbon", acToolbarYes
End Sub

'-----------------Code for click event of "Toggle" button-----------------

Private Sub Toggle_Click()
If Not CommandBars.GetPressedMSo("MinimizeRibbon") Then
CommandBars.ExecuteMSo "MinimizeRibbon"
ElseIf CommandBars.GetPressedMSo("MinimizeRibbon") Then
CommandBars.ExecuteMSo "MinimizeRibbon"
End If
End Sub


DISCLAIMER

It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. Access Guru will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.