[VBA] How to change state of submenu?

M

Madla

I'm trying to change the checkmark (.state) of a submenu in a menu that
I've added to the "Menu bar". (I added the submenu entries to the a
CommandBarPopup with CommandBarButtons.)
The Menu builds as expected but when I execute the following code within
a sub routine triggerted from the menu's action I can't figure out how
to turn the commandbarControl into a commandbarbutton so I can change
it's shape.

dim ctl as CommandBarControl 'I tried as CommandBarButton and
CommandBarPopup

Set myPopup = CommandBars("Menu bar").Controls(cIAMenu)
For Each
ctl In myPopup.Controls
'remove check next to menu item

ctl.State = msoButtonUp
Next

I get the following error, which I understand, as a CommandBarControl
doesn't have a .state property.
Error 438 - object doesn't support this method or property

So the question is how do I get a CommandBarButton so I can set its
state?

Interestingly enough this line works, even though I thought it also
returns a commandBarControl.
CommandBars.ActionControl.State =
msoButtonDown
Any help would be appreciated...martin
 

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