Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA auto hide ribbon in Excel 2013

Tags:

excel

vba

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:

enter image description here

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.

like image 371
Przemyslaw Remin Avatar asked Aug 29 '16 08:08

Przemyslaw Remin


People also ask

How do I hide the Ribbon in Excel 2013?

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.

How do you auto hide the Ribbon in Excel?

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.

How do you customize the Ribbon in Excel 2013?

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.


2 Answers

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

like image 142
Olandu17 Avatar answered Sep 19 '22 17:09

Olandu17


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:

enter image description here

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):

enter image description here

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

like image 32
Tyeler Avatar answered Sep 22 '22 17:09

Tyeler