使用Excel VBA在XLS文件中显示Excel 2007功能区 [英] Show Excel 2007 Ribbon in XLS file using Excel VBA

查看:407
本文介绍了使用Excel VBA在XLS文件中显示Excel 2007功能区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel的仪表板,这样在excel文件关闭之前,我想显示所有的EXCEL功能区,以便下次excel打开时,应用程序/ excel将显示功能区。目前,如果打开excel,它不会显示功能区。

 

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
应用程序.DisplayScrollBars = True
Application.ScreenUpdating = True
表格(简介)。选择

End Sub


这是一个.xls文件与宏,应该在Excel 2003和Excel 2007中工作。

此外,如果单击取消 ,我不想显示任何上述/功能区,因为用户应该获得excel仪表板的受保护的视图。

解决方案

如果功能区默认关闭,则可以通过双击其中一个选项卡(例如,首页选项卡)来再次打开该功能。



this 了解更多详情)。



但是,如果您希望在工作簿打开时写入事件,请使用 ThisWorkbook 中的 Workbook_Open() code> Excel对象。


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.

解决方案

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.

这篇关于使用Excel VBA在XLS文件中显示Excel 2007功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆