Callback - loadImage

Enables you to create a single procedure that loads all the images required for the Ribbon.
In the root node of your customisation there is a callback attribute called loadImage
This is used in conjunction with the 'image' attribute on individual controls.
The callback attribute 'loadImage' is called everytime the Ribbon asks for an image.
This allows you to define one image handler for the entire application.



The <customUI> element's loadImage attribute enables you to specify a callback that can load all images. After you set up this callback procedure, Office calls the callback procedure and passes the string from the image attribute for each control that loads images.
You do not need to implement the getImage callback multiple times, such as one time for each control that requires images.


To supply the button's image, Office calls the GetImage function.
It passes the parameter "mypic.jpg" and expects an IPictureDisp object in return.
By using this technique, you can write a single callback procedure that returns all the images your customization needs, without having to write each individual control's getImage callback.
Note that the loadImage callback is not called again when you call the Ribbon's Invalidate method or InvalidateControl method.
For the controls that need to change images dynamically at run time, use the getImage callback.


For example, you could use the code from the following example to provide your customization's images.
The getImage callback method must return a stdole.IPictureDisp type, so you usually need to convert your images to this type.
To perform these conversions, you can use the following PictureConverter class, which inherits from the AxHost class.



Add a DoEvents statement immediately after invalidating the ribbon



Use a single procedure for similar callbacks
Button_getVisible - handles all visibility callbacks then use a select-case


Always refer to a controls ID, never the Tag
2007 - you can change the visibility of a separator at runtime
custom icon sizes (32/16) generates blank error messages







© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext