Ribbon control.Label and control.Image of button in ExcelDNA 0.26
1,782 views
Skip to first unread message
KY
unread,
Jun 7, 2010, 9:32:38 AM6/7/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Excel-Dna
Intellisense tells me there are 3 readonly properties on an
IRibbonControl; Context, Id and Tag. I want to change the image and
label when a user clicks a ribbon button, something like:
Public Sub OnButtonPressed(control as IRibbonControl)
If control.Id = "Button2" And control.Image = "Off" Then
Call ServerStartRTDServer()
control.Image = "On"
control.Label = "Real Time On"
Else
Call ServerTerminateRTDServer()
control.Image = "Off"
control.Label = "Real Time Off"
End If
End Sub
How do I get access to the ribbon images and labels outside of setting
them in customui.xml?
Govert van Drimmelen
unread,
Jun 13, 2010, 8:08:47 AM6/13/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Excel-Dna
Hi,
The Ribbon extensibility model is a bit unusual.
There is no opportunity to set the 'label' or 'image' property of the
button after it is created, but there are 'getLabel' and 'getImage'
callbacks that you can set up.
To get Excel to refresh your control (or the whole Ribbon extension)
you need to set an onLoad callback (on the customUI element) which
receives an IRibbonUI interface for you to keep. This interface has
two methods - Invalidate and InvalidateControl - which you call when a
control should be refreshed.
ExcelDna can helps with the implementation of the getImage callback -
call the ExcelRibbon.LoadImage method (probably as
base.LoadImage(imageId) in your code) with the imageId of the picture
you want to show - this way you can load the images you specify in
the .dna file.
All of this can be elegantly wrapped in some classes without too much
trouble.