PDA

View Full Version : Solved: MenuMaker - disabling menu items



jofo
05-25-2008, 01:00 AM
I've been using John Walkenbach's menu maker (can't post link, being a newbie) to produce custom menus. I now wish to programmatically disable and enable the menu that it has created and do the same with submenu items.
I can disable the menu item itself on the Worksheet Menu Bar, but not the submenu items.


Public Sub test()
'Disables MyMenu
Application.CommandBars("Worksheet Menu Bar").Controls("MyMenu").Enabled = False
'Enables My Menu
Application.CommandBars(1).Controls("MyMenu").Enabled = True

'Here I am trying to disable a submenu item in the MyMenu menu, but I get a Runtime Error 5 Invalid procedure call or argument
Application.CommandBars("MyMenu").Controls("Minimize").Enabled = False
End Sub
Any help greatly appreciated.

Bob Phillips
05-25-2008, 03:59 AM
That looks okay, but to be certain it would be best to see your menu table and the create code (just in case you tweaked it, I always do <g>).

jofo
05-25-2008, 05:01 AM
I haven't tweaked anything at this stage, neither the menu table nor the code. The menu that it has created is the example menu that menu maker creates when it runs.
It seems to be the menu item that it created, in this case, MyMenu that it doesn't recognise.

Bob Phillips
05-25-2008, 05:14 AM
Application.CommandBars("Worksheet Menu Bar").controls("MyMenu").Controls("Minimize").Enabled = False

jofo
05-25-2008, 06:48 AM
Thanks XLD that works fine. I can see now that I got the number of levels wrong.