Remarks

You can customize the Ribbon user interface (UI) by using callback procedures in COM add-ins. When the host application starts, the onLoad callback procedure is called. The callback procedure then returns a IRibbonUI object pointing to the user interface (UI). YOu can use that object to invoke the Invalidate, InvalidateControl, and Refresh methods.

Example

In the following example, starting the host application triggers the onLoad event procedure that then calls a procedure which creates a IRibbonUI object representing the Ribbon UI. Next, a callback procedure is defined that invalidates all of the cached controls and then refreshes the UI.

Visual Basic for Applications
In the XML markup file: <customUI … …> In the VBA code: Dim MyRibbon As IRibbonUI Sub MyAddInInitialize(Ribbon As IRibbonUI) (You declare this function in your VBA Markup) Set MyRibbon = Ribbon End Sub Sub myFunction() MyRibbon.Invalidate() ' Invalidates the caches of all of this add-in's controls MyRibbon.Refresh() ' Refreshes the entire Ribbon UI End Sub

See also: