问题
I'm trying to remove the ribbon bar from the Excel window. Currently I'm using the following code which removes the ribbon.
excelApp.ExecuteExcel4Macro("SHOW.TOOLBAR(""Ribbon"",False)")
But it also removes everything above the cells including the title bar. I need the title bar so users can move, minimize, maximize and close the window. Ideally I would like to remove the entire ribbon but I would be satisfied if I could minimize the Icons on the Ribbon. I can minimize the ribbon icons by clicking the small black rectangle and triangle icon on the title bar so it must be possible.
回答1:
Never found a good workaround, except this clever solution in VBA that you should be able to recreate in .net.
Sub HideRibbon()
Application.SendKeys ("^{F1}")
End Sub
Ctrl+F1 is the combination to minimize the ribbon and maximize it, so you can use this as a toggle button if you really wish. You could set this up to run at workbook open if you like using simple VBA.
来源:https://stackoverflow.com/questions/13735595/remove-ribbon-from-excel