How to Auto-hide Ribbon
in Excel 2013 in VBA? I would like to achieve exactly what I get by clicking on the upper arrow icon at the right top of Excel menu marked with blue in the picture below and then clicking on the first option marked with orange:
I would be also interested in VBA switching back to the third option Show Tabs and Commands
. Important thing for me is to keep in the Excel menu the upper arrow icon (marked with blue).
I have tried hints shown in this thread: VBA minimize ribbon in Excel but I am not satisfied with results.
Attempt 1
Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",False)
This is good but hides the blue icon.
Attempt 2
CommandBars.ExecuteMso "MinimizeRibbon"
This is close to what I want. This keeps the blue icon but does not hide the entire menu. It switches to the second option displayed in the picture Show Tabs
.
Attempt 3
SendKeys "^{F1}"
The attampt does not work at all. Moreover, it is supposed to imitate the attempt 2. So even that would not satisfy me.
Right-click any of the ribbon tabs, and then select Collapse the ribbon. Right-click Ribbon display options in the lower right of the ribbon, and then select Collapse the ribbon.
Tip: Press Ctrl+F1 to show and hide your commands in the Ribbon. Click Show Tabs to display the Ribbon tabs without the commands. To access the commands in the Show Tabs option, click any of the tabs. Click Auto-hide Ribbon to hide all tabs and commands.
You can add a custom group to either a custom tab or a default tab. In the Customize the Ribbon window, under the Customize the Ribbon list, click the tab that you want to add a group to. Click New Group. To rename the New Group (Custom) group, right-click the group, click Rename, and then type a new name.
I use this for presentation purposes
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayHeadings = False
Application.DisplayFormulaBar = False
Application.DisplayFullScreen = True This is what i used to hide the ribbon
I can't see that anyone else has brought this up... This isn't a workaround, this is the actual idMSO for what I think you're looking for. This code makes my excel window look like everything is gone the same way the first option does for Auto-Hide Ribbon
.
Before the code runs, my window looks like this, in the 'Restore' size:
Running the following code:
Sub HideTheRibbon()
CommandBars.ExecuteMso "HideRibbon"
End Sub
Will make your window look like this, in the maxamized window size (just like what would happen if you were to press the Auto-Hide Ribbon
button manually):
If you want the ribbon automatically hidden when the workbook opens, put this in the workbook code:
Sub Workbook_Open()
CommandBars.ExecuteMso "HideRibbon"
End Sub
Alternatively, to achieve the same thing, you could put this code in a module:
Sub Auto_Open()
CommandBars.ExecuteMso "HideRibbon"
End Sub
If you want the window to revert back to normal, you run the exact same code again. In other words, the following code would make no visual change at all when ran because the idMSO "HideRibbon" is a toggleButton:
Sub HideTheRibbon()
CommandBars.ExecuteMso "HideRibbon"
CommandBars.ExecuteMso "HideRibbon"
End Sub
If you want a full list of all the idMSO in excel, click the following that apply to you: Excel 2013+, Excel 2010, Excel 2007
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With