我通过宏创建了一个新的Ribbbon(不是通过自定义UI编辑器),一切正常,但是,我需要隐藏通常的excel标准功能区(文件,评论,开发人员等等)。
这是我的代码:
Sub LoadCustRibbon()
Dim hFile As Long
Dim path As String, fileName As String, ribbonXML As String, user As String
hFile = FreeFile
user = Environ("Username")
path = "C:\Users\" & user & "\AppData\Local\Microsoft\Office\"
fileName = "Excel.officeUI"
ribbonXML = "<mso:customUI xmlns:mso='http://schemas.microsoft.com/office/2009/07/customui'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:ribbon>" & vbNewLine
ribbonXML = ribbonXML + " <mso:qat/>" & vbNewLine
ribbonXML = ribbonXML + " <mso:tabs>" & vbNewLine
ribbonXML = ribbonXML + " <mso:tab id='reportTab' label='Menu' insertBeforeQ='mso:TabFormat'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:group id='reportGroup' label='Options' autoScale='true'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:button id='runReport' label='Frontpage' " & vbNewLine
ribbonXML = ribbonXML + "imageMso='AppointmentColor3' onAction='Callback1'/>" & vbNewLine
ribbonXML = ribbonXML + " </mso:group>" & vbNewLine
ribbonXML = ribbonXML + " </mso:tab>" & vbNewLine
ribbonXML = ribbonXML + " </mso:tabs>" & vbNewLine
ribbonXML = ribbonXML + " </mso:ribbon>" & vbNewLine
ribbonXML = ribbonXML + "</mso:customUI>"
ribbonXML = Replace(ribbonXML, """", "")
Open path & fileName For Output Access Write As hFile
Print #hFile, ribbonXML
Close hFile
End Sub
我尝试添加此行,但它不起作用,没有错误消息,只是没有任何反应:
ribbonXML = ribbonXML + " <tab mso:tab label ='file' visible='false'>"
答案 0 :(得分:1)
您可以使用此行隐藏特定标签。在XML中的自定义选项卡之前添加它。
<tab idMso="TabDeveloper" getVisible="GetVisible"/>