Forum Discussion

ADumith's avatar
ADumith
Iron Contributor
May 10, 2023

Dashboard customization

Hello everyone, 

 

I have a dashboard made in Excel, so I wonder if there is any way to:
1.- Set disable the ribbon when the user opens the file.
2.- Lock the file so that the user can only navigate between pages and use the filter controls.

 

Thank you in advance,

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    ADumith 

    You can add the following code to the ThisWorkbook object in the Visual Basic editor:

    press "Alt + F11" to open the Visual Basic Editor and then insert the code in "ThisWorkbook".

    Private Sub Workbook_Open()
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
    End Sub

    This will hide the ribbon when the user opens the file. To show the ribbon again, the user can right-click on any of the tabs and select “Customize the Ribbon”.

     

    As for locking the file so that the user can only navigate between pages and use filter controls, you can protect the workbook structure.

    This will prevent users from adding, deleting, hiding, or renaming worksheets.

    To do this, go to Review –> Protect Workbook and enter a password if desired.

     

     

    Hope it helps you!

    • ADumith's avatar
      ADumith
      Iron Contributor
      Hello NikolinoDE,

      Thank you so much.

      I was able to hide the ribbon but I can't get them back, so I wonder what tabs are you making reference?

      Thank you again.
      • NikolinoDE's avatar
        NikolinoDE
        Gold Contributor

        ADumith 

        For close with open file

        Private Sub Workbook_Open()
            Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
        End Sub

         

        for open with closing file 

        Private Sub Workbook_BeforeClose(Cancel As Boolean)
            Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
        End Sub

         

        Insert this in ThisWorkbook and so you can have close the ribbon if you open the file and its is open again for the other files if you close the file.

Resources