24 April, 2022

Excel Interface: Hide or Restore

Normally, Excel application displays user interface (ribbon standard) like this (top and bottom parts):

The ribbon and other elements of the interface take quite a bit of screen surface area. If you have a good  reason to not display some of the elements of your workbook/worksheet then you can hide them by using the following macro:

Sub HideXLiface()
'Hide Excel interface
ActiveWindow.Caption = ""
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.DisplayGridlines = False
Application.DisplayScrollBars = False
Application.DisplayStatusBar = False
Application.DisplayFormulaBar = False
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",False)"
End Sub

The result of running the macro would look like this (top and bottom parts):


In this example I've assigned my two macros to the red and green buttons. The buttons can be located, obviously, somewhere else (out of the way) in your workbook.

To hide the elements of Excel interface I click on the red button, and to restore the interface I click on the green button. The macro assigned to the green button looks like this one:

Sub UnhideXLiface()
'Restore Excel interface
ActiveWindow.Caption = ThisWorkbook.Name
ActiveWindow.DisplayHeadings = True
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayGridlines = True
Application.DisplayScrollBars = True
Application.DisplayStatusBar = True
Application.DisplayFormulaBar = True
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
End Sub

No comments:

Post a Comment

All comments are held for moderation. I reserve the right to edit, censor, delete and - if necessary - block comments.