Execute a menu command with VBA?

S

Susan

Is it possible to execute a menuitem from the standard Excel menu with VBA code?

I have tried this (and several variations) with no luck:
MenuBars(xlWorksheet).Menus("Data").MenuItems("Form...").Execute

I am trying to open the Data form in the above code but I would like to do other things to.

And, for general knowledge, is "Commandbars" interchangeable with "MenuBars"?

Thank you
 
D

Dick Kusleika

Susan

MenuBars probably still works, but it's the old way. It's not completely
interchangeable with Commandbars because toolbars are commandbars, but not
menubars. I think the problem with your code is that xlWorksheet isn't a
proper index of a menu. Try this

Sheet1.ShowDataForm

If you want to use the menu, it would look like this

CommandBars(1).Controls("Data").Controls("Form...").Execute
 
S

Susan

Dick said:
Susan

MenuBars probably still works, but it's the old way. It's not completely
interchangeable with Commandbars because toolbars are commandbars, but not
menubars. I think the problem with your code is that xlWorksheet isn't a
proper index of a menu. Try this

Sheet1.ShowDataForm

If you want to use the menu, it would look like this

CommandBars(1).Controls("Data").Controls("Form...").Execute
Thanks, Dick
 
Top