我有下面的函数,假设将下面项目的属性设置为 True 或 False。我可以在除此之外的所有属性上执行此操作:
.Application.ExecuteExcel4Macro("Show.ToolBar(""Ribbon"", False)")
当我尝试用我的参数 boolStatus 替换 False 并运行该函数时,它不会改变。所以我放弃了,只是将其保留为 False,但我真的需要从 False 更改为 True,反之亦然,否则我的功能只能工作一半。就目前而言,我必须创建第二个函数,将行设置为 True,我很确定这是双重工作。
Module sheetView
Public xlWB As Excel.Workbook = CType(Globals.ThisWorkbook.Application.ActiveWorkbook, Excel.Workbook)
Public xlWS As Excel.Worksheet = CType(xlWB.ActiveSheet, Excel.Worksheet)
Function ViewSheets(boolStatus As Boolean) As String
'This function selects a dashboard and hides
'the gridlines, headings, tabs and toolbar.
'@parameter sheetName, calls the sheet to be selected
'@parameter status, sets the objects to view or hide
With xlWS
.Application.ScreenUpdating = False
'Disable the following controls
.Application.ActiveWindow.DisplayGridlines = boolStatus
.Application.ActiveWindow.DisplayHeadings = boolStatus
.Application.ActiveWindow.DisplayWorkbookTabs = boolStatus
.Application.DisplayFormulaBar = boolStatus
.Application.DisplayStatusBar = boolStatus
.Application.ExecuteExcel4Macro("Show.ToolBar(""Ribbon"", False)")
.Application.ScreenUpdating = True
End With
Return ""
End Function
End Module
我在那条线上做错了什么?