Search code examples
vbams-officeribbon

SplitButton GetImage Callback Not Working


I have a custom ribbon in Visio that displays correctly, except when I click to expand a SplitButton. When I expand the SplitButton, it calls the GetImage callback for my ribbon, and loads the bmp file using LoadPicture, but does not actually display in Visio. The next time I expand the SplitButton everything is fine.

Is there something I need to do in the callback to prompt the ribbon to display correctly when using a SplitButton?

We currently use a class that implements IRibbonExtensibility with callbacks for GetImage and OnAction, and they work fine for normal buttons, but we get this behavior only with SplitButton usage.

This is what I see the first time I click the drop down:

The Auto Pipe button is the top level and there should be two buttons in the SplitButton


Solution

  • The issue came down to the use of the DoEvents statement, which was added to our stack trace code in our codebase. Every time we enter a routine we push the routine name onto a call stack and then pop it on exit, but this routine also had added the DoEvents statement to help break out of any loops during development.

    It would seem that, since we add the ribbon via a Document Created/Opened event, executing DoEvents must be causing Visio to not correctly process the ribbon loading callbacks. Removing the DoEvents statement fixed the problem.