Sunday, May 29, 2011

To avoid, that the State of global IRibbonUI Ribbon object

In today's post offers Excel MVP Ron de Bruin a solution to a common problem that occurs if you use RibbonX and VBA, customize Ribbon. For more tips and links to Excel add-in the Ron's Web site: http://www.rondebruin.nl/.

See more light bulb photos at Office.com/imagesIt is a common problem when you work with the Ribbon using RibbonX and VBA. Ribbon object (that is initialized when Excel loads the file) can lose the reference to the Ribbon, which is that your code can no longer say mean Excel to update your Ribbon customizations.
There is simply no simple, restore integrated fashion that handle for the Ribbon, if it problems in or with your code. The only way to fix it is close and not very user friendly reopen your workbook.

But MVP Rory Archibald came with a great idea in a post in the Forum MrExcel. In the example in the workbook that you can download on this page (see below) is based on Rory's idea and works in 32-bit Excel 2007 and Excel 2010 32-bit - and 64-bit.

You store the pointer to the IRibbonUI in a cell (or the name or where ever) and it use CopyMemory then get back, if the State is lost.

You can test this sample workbook this method, the Ribbon handle restored if it is lost.

Download: Loss of the Ribbon state.zip.  

Note: decided I me not the workbook code RibbonX to this page add, because, if you work the code in the workbook can see, it is much clearer. If all this is new to you, I suggest that you click on the link below, with my Ribbon page start then.

For more information about customizing the Ribbon, see to change the Ribbon in Excel 2007 or Excel 2010.

--Ron de Bruin


View the original article here

No comments:

Post a Comment