I have an xlam AddIn which creates a custom tab in Excel. I want to allow users to choose their own keytip for this tab using the getKeytip functionality of Ribbbon XML, e.g.
XML: <tab id="rbnTestTab" label="Test Tab" getKeytip = "getKeytip">
I have a macro which gets the user's value from an InputBox, pastes it into a named range on a sheet, and then uses the .Invalidate and .InvalidateControl on the Ribbon object and the control "rbnTestTab" respectively, therefore calling the GetKeytip for the tab and setting the keytip.
VBA: Public Sub GetKeytip(control As IRibbonControl, ByRef label)
'get keytip function sets the keytip of a control according to its ID
'take the value stored on the worksheet
label = CStr(wksKeyTip.Range("rngKeytip").Value)
This code works fine in Excel 2007, but isn't working at all in Excel 2010, does anyone have any suggestions why not? I can't figure it out and there isn't anything in the usual useful places (Ron de Bruin's site, Ken Puls' blog, Msdn) mentioning any compatibility issues between Ribbon XML in 2007-2010.
Two additional notes which may help (or further confuse!):
1. The VBA callback is different between 2007-2010 (ByRef argument has different name); changing the argument to be called "returnedVal" stops the code working in 2007, but doesn't make it work in 2010, which is odd!:
2. If you use this code and try to set a keytip which is already assigned, e.g. "H" (Home tab), then the getKeytip fails and you get "Y" or "Y1" as the keytip on your tab, and this then cannot be changed to anything else after that by rerunning the macro/invalidate routines - you have to restart the workbook.
VBA: Sub GetKeytip (control As IRibbonControl, ByRef label)
VBA: Sub GetKeytip(control As IRibbonControl, ByRef returnedVal)
Any help on how this works between 2007 and 2010 greatly appreciated! I also posted the question here: http://www.mrexcel.com/forum/showthread.php?t=544262