getVisible callback for ribbon

710 views
Skip to first unread message

mauricekoster

unread,
Oct 11, 2011, 12:51:30 PM10/11/11
to Excel-DNA
Hi,

I created in my .dna a customui for a ribbon. I have the follow group:

<group id="grpConfig" tag="GRP_CONFIG" visible="true"
getLabel="rxshared_getLabel">

I have in a VB.NET class the following function defined:

'============================================================================
Imports ExcelDna.Integration
Imports ExcelDna.Integration.CustomUI

Public Class MyRibbon
Inherits ExcelRibbon
Implements IExcelAddIn

Public Sub rxshared_getLabel(ByVal control As IRibbonControl,
ByRef returnedVal As Object)
'
' Code for getLabel callback. Ribbon control group
'
Dim r_tag
r_tag = control.Tag
If r_tag = "" Then r_tag = control.Id
returnedVal = "Some text " & r_tag

End Sub
End Class
'============================================================================

Somehow the callback function (rxshared_getLabel) is not called. Am I
missing something?
I also want to use getVisible in the future.

Govert van Drimmelen

unread,
Oct 11, 2011, 1:10:42 PM10/11/11
to Excel-DNA
Hi Maurice,

I think problem is just the signature of your callback.
I had not realized this before, but the signatures look different
under VBA and under VB.NET - in particular the callbacks are Functions
in VB.NET when they are Subs in VBA taking a ByRef parameter for the
'return' value. Thanks for alerting me to this difference.

So I think you should try

Public Function rxshared_getLabel(ByVal control As IRibbonControl)
As String
'
' Code for getLabel callback. Ribbon control group
'
Dim r_tag
r_tag = control.Tag
If r_tag = "" Then r_tag = control.Id
Return "Some text " & r_tag
End Sub

I had a look at this document, which shows both the VBA and the VB.NET
(they call it Visual Basic) signatures for all the callbacks.
http://msdn.microsoft.com/en-us/library/aa722523(v=office.12).aspx

I haven't tried this myself, so if it is still not fixed for you,
please write again and I can test with an example.

Regards,
Govert

mauricekoster

unread,
Oct 11, 2011, 1:47:51 PM10/11/11
to Excel-DNA
Hi Govert,

Dank je wel. It works!

Regards,
Maurice

On 11 okt, 19:10, Govert van Drimmelen <gov...@icon.co.za> wrote:
> Hi Maurice,
>
> I think problem is just the signature of your callback.
> I had not realized this before, but the signatures look different
> under VBA and under VB.NET - in particular the callbacks are Functions
> in VB.NET when they are Subs in VBA taking a ByRef parameter for the
> 'return' value. Thanks for alerting me to this difference.
>
> So I think you should try
>
>     Public Function rxshared_getLabel(ByVal control As IRibbonControl)
> As String
>         '
>         ' Code for getLabel callback. Ribbon control group
>         '
>         Dim r_tag
>         r_tag = control.Tag
>         If r_tag = "" Then r_tag = control.Id
>         Return "Some text " & r_tag
>     End Sub
>
> I had a look at this document, which shows both the VBA and the VB.NET
> (they call it Visual Basic) signatures for all the callbacks.http://msdn.microsoft.com/en-us/library/aa722523(v=office.12).aspx
Reply all
Reply to author
Forward
0 new messages