excelvbaribbonribbon-control

How to display tabs and ribbons when closing Excel?


I've got a macro which auto hides ribbons when this excel file opens however, when I close the file I would like these to reappear so when using other files this means I won't have to format them each time.

enter image description here

I've written the below code for when excel opens/closes. But cannot get the ribbons to reappear without manually clicking.

Private Sub Workbook_Open()

Application.CommandBars.ExecuteMso "HideRibbon"
ActiveWindow.DisplayGridlines = False

ActiveWindow.DisplayHeadings = False

Application.DisplayFormulaBar = False

Application.DisplayFullScreen = True
End Sub


Sub Auto_close()
Application.CommandBars.ExecuteMso "hideRibbon"
Application.CommandBars.ExecuteMso "hideRibbon"

ActiveWindow.DisplayGridlines = True

ActiveWindow.DisplayHeadings = True

Application.DisplayFormulaBar = True
End Sub

Solution

  • This displays the ribbon:

    Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"", True)"

    This hides the ribbon:

    Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"", False)"