No getLabel or getVisible functionality for custom Ribbon tab?

Started by dolomike, January 18, 2018, 07:21:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dolomike

I've been scratching my head for a couple days over this and it seems that functionality that works with Excel doesn't work in Visio.

I've been trying to dynamically update a custom ribbon using the getVisible and getLabel parameters in the XML file but the callbacks never get called. I saw one post which seemed to confirm my suspicion that Visio doesn't support getVisible and getLabel but can't find any concrete yes/no answers to this.

Is this the case?

Surrogate


dolomike

Ok, ignore the Excel vs Visio issue. Something else is going on.

I can use the code from https://msdn.microsoft.com/en-us/library/ee390805(v=office.12).aspx and get it to work in Visio no problem.

The issue seems to be how I'm creating the ribbon. I'm using: app.RegisterRibbonX myRibbon and a Ribbon class to implement the custom Ribbon. OnAction callbacks work but I can't get getVisible or getLabel callbacks to fire.


XML snippet:
<group id="grpInfo" getVisible="GetVisible" label="Information" tag="DevelTest">
<labelControl id="FileName_lblUser" getLabel="getlblUser"/>
<labelControl id="FileName_lblDate" getLabel="getlblDate"/>
</group>


Callback:
Public Sub GetVisible(control As IRibbonControl, ByRef returnedVal)
MsgBox "GetVisible"
    returnedVal = True
End Sub


Everything else works fine.

metuemre

Callback functions that I use for getVisible and getLabel are below and they work in Visio 2013

Public Sub GetVisible(control As IRibbonControl, ByRef MakeVisible)
Select Case control.ID
    Case "TabInsert"
        MakeVisible = False
End Select
End Sub

Public Function getLabel(control As IRibbonControl) As String
    Select Case control.ID
        Case "help"
            getLabel= "TestLabel"
    End Select   
End Function

dolomike

It seems you need to specify the callbacks as functions and with specific arguments and return values otherwise it doesn't work. I couldn't get your GetVisible Sub to work and had to use the Function structure below. 


Public Function getVisible(Control As Office.IRibbonControl) As Boolean

Select Case Control.ID
   Case "id_1"
        GetVisible = True
   Case "id_2"
        GetVisible = False
   Case Else
        MsgBox "No GetVisible action for ID: " & Control.ID, vbInformation, "Warning"
        GetVisible = False
End Select
 
End Function



Public Function getLabel(ByVal Control As Office.IRibbonControl) As String
    getLabel = "Your Label"
End Function


Thanks for getting me part way there!