VBA minimize ribbon in Excel

Measure Ribbon height, toggle it, measure again and if taller, re-toggle. Best also to set Application.Screenupdating = false.

ht1 = Application.CommandBars("Ribbon").Height
SendKeys "^{F1}", False
DoEvents
ht2 = Application.CommandBars("Ribbon").Height
If ht2 > ht1 Then SendKeys "^{F1}", False

And I do hate it when folk question why you want to do what you want. I have a Dictator App and need 100% control over the interaction with Excel.


Not sure when you are trying to call this but this will work to minimize the ribbon if its open

If Application.CommandBars("Ribbon").Height >= 150 Then
    SendKeys "^{F1}"
End If

Open Ribbon minimum size seems to be 150 so this will only toggle if it's open

Tags:

Excel

Vba