Skip to main content

IRibbonUI.Invalidate method

Table of contents
  1. Syntax
  2. Remarks
  3. Example

Invalidates the cached values for all of the controls of the Ribbon user interface.

Syntax

expression.Invalidate

expression An expression that returns an IRibbonUI object.

Remarks

You can customize the Ribbon UI by using callback procedures in COM add-ins. For each of the callbacks that the add-in implements, the responses are cached.

For example, if an add-in writer implements the getImage callback procedure for a button, the function is called once, the image loads, and then if the image needs to be updated, the cached image is used instead of recalling the procedure. This process remains in place until the add-in signals that the cached values are invalid by using the Invalidate method, at which time, the callback procedure is again called and the return response is cached. The add-in can then force an immediate update of the UI by calling the Refresh method.

Example

In the following example, starting the host application triggers the onLoad event procedure that then calls a procedure that creates an object representing the Ribbon UI. Next, a callback procedure is defined that invalidates all of the controls on the UI 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>