How to access sub-menu item from VBA

G

Guest

Hi

I am using below code to change the menu button's caption. But it only changes the button on the first level, it doesn't change the sub-menu items

CommandBars("MyMenu").Controls contains only first level menu (like "File", "Edit", "View", "Tools", "Windows" of Ms Access' menu). How to access sub-menu items of given menubar

Public Function ChangeMenuLanguage(
Dim cbctr As CommandBarContro

On Error Resume Nex

For Each cbctr In CommandBars("MyMenu").Control
cbctr.Caption = "New name

Nex

End Functio

Thank
Tran Hong Quang
 
A

Alex Dybenko

submenu (popup) control has also controls collection

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com


Tran Hong Quang said:
Hi,

I am using below code to change the menu button's caption. But it only
changes the button on the first level, it doesn't change the sub-menu items.
CommandBars("MyMenu").Controls contains only first level menu (like
"File", "Edit", "View", "Tools", "Windows" of Ms Access' menu). How to
access sub-menu items of given menubar?
 
G

Guest

Hi Alex
What is the control collection name of submenu/popup? and how to access to only the submenu under the menu being displayed

Best Regard
Tran Hong Quang
 
A

Alex Dybenko

say you have a menu called MyMenu, it have submenu Item1 with items:
Item11
Item12
etc
so to get Item11 you can write:

CommandBars("mymenu").Controls("Item1").commandbar.controls(1).caption

HTH
--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com


Tran Hong Quang said:
Hi Alex,
What is the control collection name of submenu/popup? and how to access
to only the submenu under the menu being displayed ?
 

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

Top