Show Excel 2007 Ribbon in XLS file using Excel VBA

馋奶兔 提交于 2019-12-10 22:53:04

问题


I have a excel dashboard which works such that before the excel file is closed, I would like to display all the EXCEL ribbon, so that next time excel is opened, the application / excel will show the ribbon. At present, it does not show the ribbon if excel is opened.


Private Sub Workbook_BeforeClose(cancel As Boolean)

    On Error Resume Next

    Application.ScreenUpdating = True
    ActiveWindow.DisplayWorkbookTabs = True
    Application.DisplayFormulaBar = True
    Application.DisplayFullScreen = False
    Application.DisplayStatusBar = True
    Application.DisplayScrollBars = True
    Application.ScreenUpdating = True
    Sheets("Introduction").Select  

End Sub


This is an .xls file with Macro and supposed to work in Excel 2003 and Excel 2007.

Also, if "Cancel" is clicked, I do not want to show any of the above / ribbon, as user is supposed to get a protected view of the excel dashboard.


回答1:


If the ribbon is closed by default, you can open it again by double clicking on one of the tabs (for instance, the Home tab).

(See this for more details).

If, however, you wish to write an event to take place when the workbook opens, then use the Workbook_Open() event from the ThisWorkbook Excel Object.




回答2:


try this Application.ExecuteExcel4Macro " show.toolbar(""Ribbon"",true)" to hide Application.ExecuteExcel4Macro " show.toolbar(""Ribbon"",false)"



来源:https://stackoverflow.com/questions/3527645/show-excel-2007-ribbon-in-xls-file-using-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!