隐藏但在自定义功能区上显示多个其他选项卡组,这也需要具有隐藏功能,反之亦然

时间:2019-05-08 18:11:25

标签: excel vba ribbon

我有一个自定义功能区,我有多个组,我需要隐藏1个组,但保持其他组显示。该示例显示了仅显示一个组而不显示另一个组的能力。有人知道我可以如何修改以显示其他组吗?

xml:

<group id="MyCustomGroup2" label="First Controls"  getVisible = "GetVisible" tag="First" >  
     <button id="customButton3" label="Label 1" size="normal" onAction="TransferNA" imageMso="FileServerTransferDatabase" tag="transfer"  />    
</group>    

<group id="MyCustomGroup3" label="Second Controls" getVisible = "GetVisible" tag="Second">  
     <button id="customButton5" label="Label 2" size="normal" onAction="HideInfor" imageMso="FormHeaderOrFooterShowHide" /> 
</group>    

<group id="MyCustomGroup4" label="Third Controls" getVisible = "GetVisible" tag="Third">    
     <button id="customButton4" label="Label 3" size="normal" onAction="ShowInfor" imageMso="FormHeaderOrFooterShowHide" /> 
</group>

Dim Rib As IRibbonUI
Dim MyTag As String
Sub RibbonOnLoad(ribbon As IRibbonUI)
    Set Rib = ribbon
End Sub

Sub GetVisible(control As IRibbonControl, ByRef visible)
    If control.Tag Like MyTag Then
        visible = True
    Else
        visible = False
    End If
End Sub

Sub RefreshRibbon(Tag As String)
    MyTag = Tag
    If Rib Is Nothing Then
        MsgBox "Error, restart your workbook"
    Else
        Rib.Invalidate
    End If
End Sub


Sub HideFirstGroupButShowSecondAndThird()
    Call RefreshRibbon(Tag:="First") 'Hide First but show Second and Third???????
End Sub

0 个答案:

没有答案