I have a custom ribbon and one of the buttons on it (image and label for the button) are supposed to change based on what happens in one of the forms (so, essentially, it's supposed to change when values in a table change and making changes in the form is the trigger for the change).
On the CLOSE button of the form I have the following code:
sbRefreshRibbon
MyRibbon.Invalidate
and here is what the procedure does, so the MyRibbon.Invalidate part is probably redundant:
Public Sub sbRefreshRibbon()
On Error GoTo RestartApp
MyRibbon.Invalidate
On Error GoTo 0
Exit Sub
RestartApp:
MsgBox "Please restart Application for Ribbon changes to take effect", _
vbCritical, "Ribbon Refresh Failed"
End Sub
In any case, sometimes, when clicking CLOSE I get the "Please restart Application for Ribbon changes to take effect" error. After restarting, all is well, the label is correct and so is the image but, how can I make the label and image change without errors and restarts?
CodePudding user response:
There is no need to call the Invalidate
method of the IRibbonUI
interface multiple times. You need to left a single call as soon as your form is closed.
Also you may consider using the InvalidateControl method of the IRibbonUI
interface instead. It allows invalidating the cached value for a single control (not the whole custom UI) on the Ribbon user interface.