You’re correct in that the way you mentioned works in 2003, and also that your toolbar will manifest in the add-ins tab in 2007.
The bad news… you can’t do this using VBA alone. The easiest way to do what you are after is to save the file as an xlam, create XML code to set the startFromScratch attribute to true, and specifically declare tab idMso=”TabAddIns” visible=”true”
Any way you slice it, though, you’ll need to write some XML.
Hope that helps,
Ken
]]>Dim c as commandbar
For each c in application.commandbars
c.enabled=false
next
Please help.
]]>Out of curiosity, is the Add-in loaded when you open the document in this way?
]]>So, I have an add-in in which I updated xml with a customUI. This menu loads when I start up excel, but if I open a specific workbook direct from my documents, the menu doesn’t load.
Any help would be great!
KML
]]>Unfortunately, no. This is the single biggest issue that we have when creating building and debugging ribbon modifications. I’m hoping that we’ll see this ability in Office 14, but only time will tell.
Right now, if you lose your RibbonUI object, the only recourse is to reload the workbook/addin to reset it. It’s a one shot deal.
]]>In one of your examples you had the following code:
Dim cRibbon as IRibbonUI
Private Sub sbCustomUI_onLoad(ribbon as IRibbonUI)
Set cRibbon=ribbon
End Sub
If cRibbon gets set to Nothing is there a way to reset it?
]]>Essentially, the GetContent procedure can be called each time the menu is clicked by calling the InvalidateControl method of the iRibbonUI interface.
Based on the example above, there are 3 changes which need to be made to have the menu dynamically populated when clicked:
Step 1:
In the Microsoft Office 2007 CustomUI Editor, tell Excel to give you an iRibbonUI interface by adding the onLoad callback to the customUI element to the XML:
Step 2:
In the VBA module, create a global variable which will be used to invalidate the menu. The variable will be initialized when the workbook is opened/XML loaded.
Dim cRibbon as IRibbonUI
Private Sub sbCustomUI_onLoad(ribbon as IRibbonUI)
Set cRibbon=Ribbon
End Sub
Step 3:
Add the following line of code at the end of the GetContent procedure to dynamically rebuild the menu each time it’s clicked:
cRibbon.InvalidateControl “menu1″
Hope this helps,
Ray R. Gable, Jr.
]]>BUT… Is there a way to reset the dynamic menu? The first time you open the dynamic menu, the GetContent-procedure is called. But only once. Next time when I open the menu the procedure is not called since the dynamic menu is already populated.
I would like to call the GetContent procedure each time i open the menu. Is that possible?
]]>My blog has issues with displaying XML. Can you email that to me? (You can send me the workbook if you like as well.)
Email is ken at excelguru dot ca
Thanks,
Ken
]]>