如何在关闭时显示标签和功能区Excel?

How to display tabs and ribbons when closing Excel?

我有一个宏,当这个 excel 文件打开时,它会自动隐藏功能区,但是,当我关闭文件时,我希望这些功能区重新出现,所以当使用其他文件时,这意味着我将不必每次格式化它们。

我已经为 excel opens/closes 编写了以下代码。但是如果不手动点击就无法让丝带重新出现。

Private Sub Workbook_Open()

Application.CommandBars.ExecuteMso "HideRibbon"
ActiveWindow.DisplayGridlines = False

ActiveWindow.DisplayHeadings = False

Application.DisplayFormulaBar = False

Application.DisplayFullScreen = True
End Sub


Sub Auto_close()
Application.CommandBars.ExecuteMso "hideRibbon"
Application.CommandBars.ExecuteMso "hideRibbon"

ActiveWindow.DisplayGridlines = True

ActiveWindow.DisplayHeadings = True

Application.DisplayFormulaBar = True
End Sub

试试这个

Private Sub Workbook_Open()
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayHeadings = False
Application.DisplayFormulaBar = False
Application.DisplayFullScreen = True
End Sub

Sub test()
Application.DisplayFullScreen = False
ActiveWindow.DisplayGridlines = True
ActiveWindow.DisplayHeadings = True
Application.DisplayFormulaBar = True
Application.CommandBars("Standard").Visible = True
End Sub

这显示功能区:

Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"", True)"

这会隐藏功能区:

Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"", False)"