CommandBars/SetMenuItem help please

smig

Registered User.
Local time
Today, 15:41
Joined
Nov 25, 2009
Messages
2,209
I built my oun menu for the application.
I want to run some code that will change one of the sub commands to be checked/unchecked

can't find how to do it :mad:


Access2003, winXP
 
seriousely, no one here know how to change a commandbar submenu ?
:(
 
Yo SMIG can you post your DB?
 
it's big - 10mb
what do you need it for?
 
after a long search over the net I found the answer. it's not in the help, nor I could find it in the MSDN :(

refering to your menubar (CommandBar):
Application.CommandBars("CommandBar_Name").

refering to a menu in the CommandBar:
Application.CommandBars("CommandBar_Name").Controls(MenuIndex).
you can also use the Menu Caption

refering to a sub menu (The most tricky part):
Application.CommandBars("CommandBar_Name").Controls(MenuIndex).CommandBar.Controls(SubMenuIndex).
again, you can use the Menu and SubMenu captions

the most relevant properties: enabled, visible and faceID
there is no way to set a menu as "Checked" you should find an icon you like to be used and use the faceID property

look in the Access help for more properties, events, and methods
if you try to look for the CommandBar object help don't waste your time (Keyword not found).
go to the CommandBars object help and go from there.
 
The syntax you specified below for refering to a submenu worked fine in AC2002 and 2003. but in Migrating my application to AC2010 this syntax is generatign an error . I have a reference to Ms Office 14.0 Object Library but it is not working.
Does anyone know the proper syntax for AC2010?

refering to a sub menu (The most tricky part):
Application.CommandBars("CommandBar_Name").Controls(MenuIndex).CommandBar.Controls(SubMenuIndex).
again, you can use the Menu and SubMenu captions
Any help is greatly appreciated.

Bill





after a long search over the net I found the answer. it's not in the help, nor I could find it in the MSDN :(

refering to your menubar (CommandBar):
Application.CommandBars("CommandBar_Name").

refering to a menu in the CommandBar:
Application.CommandBars("CommandBar_Name").Controls(MenuIndex).
you can also use the Menu Caption

refering to a sub menu (The most tricky part):
Application.CommandBars("CommandBar_Name").Controls(MenuIndex).CommandBar.Controls(SubMenuIndex).
again, you can use the Menu and SubMenu captions

the most relevant properties: enabled, visible and faceID
there is no way to set a menu as "Checked" you should find an icon you like to be used and use the faceID property

look in the Access help for more properties, events, and methods
if you try to look for the CommandBar object help don't waste your time (Keyword not found).
go to the CommandBars object help and go from there.
 
how should a command bar be declared ?

I saw this in the help:
for each cbar in commandBars
debug.print cbar.name
next cbar


but what type of variable cbar is ?
 
Dim cbar As CommandBar
or
Dim cbar As Object
 
thanks
I also thought it should be CommandBar but it's not in the var type list
Object will do :)
 
smig

I see you found the solution. I just had exactly the same problem - trying to grey out menus and change the icon. Not easy at all. I used the blue arrows as pointers, for what I wanted to do.
 
for this I found the solution 3 months ago (see #5)
tricky part is to get the sub menues, as this is not in the help

for the icons I use the V - Dib Pictures tool (from the V-Tools collection) to get the icon dibID to be used.
 

Users who are viewing this thread

Back
Top Bottom