Skip to main content

IRibbonUI object

Table of contents
  1. Remarks
  2. Example

The object that is returned by the onLoad procedure specified on the customUI tag. The object contains methods for invalidating control properties and for refreshing the user interface.

The IRibbonUI object does not generate events in its interaction with the user. Instead, ribbon elements perform callbacks to your code, and the linkage between ribbon elements and your code is defined in the XML that describes your ribbon additions.

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). Use that object to invoke the InvalidateInvalidateControl, and Refresh methods.

Example

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

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="MyAddInInitialize">
	<ribbon>
		<tabs>
			<tab id="customTab" label="MyTab" insertAfterMso="TabHome">
				<group id="customGroup" label="Custom Tab">
					<button id="customButton" label="Custom Button" imageMso="HappyFace" size="large" onAction="Callback" />
				</group>
			</tab>
		</tabs>
	</ribbon>
</customUI>
Dim MyRibbon As IRibbonUI
 
Sub MyAddInInitialize(Ribbon As IRibbonUI)
    Set MyRibbon = Ribbon
    MyRibbon.Invalidate 'Invalidates the caches of all of this add-in's controls
End Sub

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>