In excel 2007, we can simply right-click on a ribbon and select “Minimize Ribbon” and minimize it.
I tried
Application.ExecuteExcel4Macro("show.toolbar(\"ribbon\",false)");
which hides the entire tape, but I do not want to hide the whole tape.
I even tried
Application.SendKeys("^{F1}", true);
but it is not reliable, because sometimes it does not work correctly.

Is there a way to do this using C # VSTO code?
I read a lot about the toggleribbon() function, but could not find a way to use it.
EDIT: There is a way you can really find if the tape is already minimized. I used
Office.CommandBars cbs = null; cbs = Application.CommandBars; foreach (Office.CommandBar cb in cbs) { if (cb.Name == "Ribbon") { if (cb.Height > 90) { this.Application.ActiveWindow.Activate();
Sangram nandkhile
source share