Execute a menu command with VBA?

  • Thread starter Thread starter Susan
  • Start date Start date
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

auto enable macros 5
Stripping down excel 2
menu bar and error 91 3
Using Excel 2007 with Excel 2003 template 1
Delete MenuItem 3
How to add entries in the Menue bar with VBA code? 1
Validation... 1
Close routine 2

Back
Top