I have a template with a customized ribbon. The customizations remove the paragraph and style tabs and rebuild a subset of the paragraph tab. The customization also adds three custom tabs.
If the XML for the CustomUI is written using the Visible attribute rather than getVisible the customized ribbon appears and functions as it is designed to do.
The initialization behind the customization is lengthy so to allow the document to be opened for quick edits there is a separate button which runs the initialization. This means that some buttons in the Custom tabs cause errors as the data structures behind them are not initialized.
To avoid such errors I have changed the visible attribute from 'visible ="true"' to the callback 'getVisible = "get_visible"' in the Custom XML. The callback get _visible simply returns a boolean value (flag) which is false if initialization has not been done and true if it has been done.
The visibility of built in elements is controlled by 'not flag' and customized elements by 'flag' so changing flag from false to true and then invalidating the ribbon should hide the built in elements I want hiding and show the customized elements.
When I load the document everything is correct. No built in elements are hidden and no custom elements are visible.
However, when I run the initialization I end up with an incorrect Ribbon
The built in elements I have set to be hidden are hidden
The subset of the paragraph tab that I want to be visible is visible
The custom tabs I want to be visible are NOT visible.
I can't for the life of me work out why.
The current state of the get_visible code is below. user_customui_activated is the 'flag' variable.
Code:
Sub get_visible(control As IRibbonControl, ByRef returnVal)
Select Case control.ID
Case IDMSO_BULLETS_GALLERY_WORD
returnVal = Not user_customui_activated
Debug.Print control.ID, Not user_customui_activated
Case IDMSO_NUMBERING_GALLERY_WORD
returnVal = Not user_customui_activated
Debug.Print control.ID, Not user_customui_activated
Case IDMSO_MULTI_LEVEL_LIST
returnVal = Not user_customui_activated
Debug.Print control.ID, Not user_customui_activated
Case IDMSO_GROUP_STYLES
returnVal = Not user_customui_activated
Debug.Print control.ID, Not user_customui_activated
Case IDMSO_GROUP_PARAGRAPH
returnVal = Not user_customui_activated
Debug.Print control.ID, Not user_customui_activated
Case rbnID_READ_user_CMC
returnVal = user_customui_activated
Debug.Print control.ID, user_customui_activated
Case rbnID_ARC_PARAGRAPHS
returnVal = user_customui_activated
Debug.Print control.ID, user_customui_activated
Case rbnID_TAB_UTILITIES
returnValue = user_customui_activated
Debug.Print control.ID, user_customui_activated
Case rbnID_TAB_user
returnValue = user_customui_activated
Debug.Print control.ID, user_customui_activated
Case rbnID_TAB_REGULATORY
returnValue = user_customui_activated
Debug.Print control.ID, user_customui_activated
Case Else
MsgBox "getVisible called for " & control.ID, vbOKOnly
End Select
End Sub
an example of the xml for an IDMSO and rbnID element are provided below.
Code:
<group
idMso="GroupStyles"
getVisible="get_visible"/>
<tab
label="Utilities"
id="Tab_Utilities"
getVisible="get_visible">
<group
label="Style Management"
id="StyleManagement">
<button
id="Read_User_CMC_Resources"
label="Re-Read Resources"
onAction="button_onAction"
getSupertip = "get_supertip"
getVisible = "get_visible"/>
</group>
</tab>
Output from the debug statements is
On load
ArcParagraphs False
Tab_Utilities False
Tab_user False
Tab_Regulatory False
GroupParagraph True
GroupStyles True
After initialisation
GroupParagraph False
GroupStyles False
ArcParagraphs True
Tab_Utilities True
Tab_user True
Tab_Regulatory True
Any suggestions as to what to investigate next would be welcome.