RibbonX Control Label

oseitutuSamuel

Board Regular
Joined
Jul 31, 2015
Messages
82
Hello Fellows,

I have created a RibbonX dynamic buttons. The progran reads a list in Excel column to create the buttons for the control. The entries in the Excel column are used as labels for the
dynamic buttons. A common Callback routine is used for each button. That is, the butt******* for each button calls a single Callback routine. Because of that I need to know
the label for the button that was clicked so I can take action. The Callback routine is as shown below:
Please notice that the routine receives the button that is clicked as a control. The second line tries to show me the label of the button that is passed to the routine.

However I get the error that the property is not supported. I thought I should be able to retrieve the label property that I have set for a button.
Any help, please
Thanks

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Sub rxbtnDyna_onAction(control As IRibbonControl)
MsgBox control.Label
If lngNoOfCompanyVideos < 2 Then Exit Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]lngNoOfCompanyVideos = lngNoOfStoredVideosAfterUpload
'Callback for button onAction
If control.ID = "rxbtnRefresh" Then
rxIRibbonUI.InvalidateControl ("rxdmnuCompanyVideos")
ElseIf control.ID <> "rxbtnAddVideo" Then
Call PlayVideo(control)
End If
End Sub[/FONT]
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
When the code creates the buttons, it has to create a unique ID for each one. You need to reference the control.ID property. There is no way to get the label of the clicked button.

When I name buttons, I usually give them a name like btnProcedureToRun1. When I strip off the lower case prefix and the numeric suffix, I am left with ProcedureToRun, which is of course the procedure I want to run when that button is clicked.
 
Upvote 0
When the code creates the buttons, it has to create a unique ID for each one. You need to reference the control.ID property. There is no way to get the label of the clicked button.

When I name buttons, I usually give them a name like btnProcedureToRun1. When I strip off the lower case prefix and the numeric suffix, I am left with ProcedureToRun, which is of course the procedure I want to run when that button is clicked.


Thank you Peter. It is strange that we can set a property (label) and not be able to read it. And thanks for your technique which I believe will come in handyin the future. For now, because I am using the text that is entered in Excel cells (by the user) as labels, I dont have control over what the label text will be so I cannot manipulate it very much. To solve my problem, I realised that we can read the Tag property of the control (button). So I set both the Tag and the Label properties to the same text (from Excel) and retrieved the Tag property. The problem here is that if I need to set the Tag property to something different, this technique won't work, but at least for this project this is not the case.
Thanks again for your help and have a nice day.
Sam
 
Upvote 0
Ha ha, no problem.

You could use the label as the basis for the control ID. If the label is "List All Files" you could assign an ID of "btnListAllFiles1". This is probably just as good as knowing the label.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top