PDA

View Full Version : Refresh ribbon with code



cagataybaser
09-17-2014, 05:19 AM
Hello everyone,I created a custom ribbon for myself using xml
I have a part in xml code like this

<checkBox id = "Fnew" getLabel="CallbackGetLabel" getPressed="GetPressed" onAction="KOLONAC" />

and vba code for this part is


Dim bChk(0 to 2) As Boolean
Public objRibbon As IRibbonUI
Private Sub o n l o a d(ribbon As IRibbonUI)
Dim i As Long
Set objRibbon = ribbon
bChk(0) = True
End Sub

Function GetChkBox(ByVal sString) As String
Select Case sString
Case "Fnew"
GetChkBox = "0"
End Select
End Function

Sub GetPressed(control As IRibbonControl, ByRef Button)
Button = bChk(GetChkBox(control.ID))
End Sub

Sub CallbackGetLabel(control As IRibbonControl, ByRef Label)
On Error Resume Next
Select Case control.ID
Case "Fnew"
Label = Range("B12").Value
End Select
End Sub





And when I change range("b12").value with another macro,getpressed is not shown anymore.
Can you help me about that?
Best Regards

snb
09-17-2014, 08:28 AM
crossposted here http://www.excelguru.ca/forums/showthread.php?3517-Refresh-ribbon-with-code

Aflatoon
09-18-2014, 03:06 AM
Are you invalidating the control/ribbon? If not, the callback won't get called to update the label text.

fjorissen
03-10-2018, 03:13 PM
Simply: objRibbon.invalidate