I really need help with this so I'm reasking the question and giving it 500 pts:
I'd like to programatically add a commandbar button (msoControlButton) to a 'menu' (msoControlPopup) and I'd like it to behave the same was as if I'd have manually chosen to:
1. customize the menu bars, created/selected my custom toolbar,
2. Dragged on to that toolbar a 'NewMenu'
3. On to that new menu, dragged a 'form', from the AllForms section
AFAICT, this means that my commandbutton has to have a builtin ID of 1837 and a parameter which is the name of the desired form.
so here is what I imagine the code should resemble:
Dim z As CommandBarButton
Set z = Application.CommandBars("MyMenu").Controls(1).controls.Add(msoControlButton, 1837, "Form1")
When I try this I get this error:
-2147467259(800004005) 'Method "Add" of object commandbarcontrols failed' -