I have a custom menu on a commandbar with sub-menus of CommandBarPopup. For some of these, only a single value is allowed to be selected.
So when a sub-menu item is clicked on, the onaction command makes sure the state value of the selected item is set to msoButtonDown and all the rest to msoButtonUp.
When an item is already selected (i.e. checked), if you click on it again, the code does the same thing. It makes sure that item is msoButtonDown and the rest are msoButtonUp.
However, the checkmark disappears. If you select a different menu and then go back, the checkmark shows up in the correct place. It seems that Excel VBA has some default behavior on the click event that gets rid of the checkmark if one is already there.
I have tried a number of iterations involving making the menu item invisible (i.e visible = false) and then visible again, having screenupdating be set to false and then to true etc. The checkmark will not re-appear until you click on a different menu and then go back again.
How can I programmatically make the checkmark stay there when a CommandBarPopup that is already checked is clicked?
' this works great, except when the checkmark is not supposed to toggle
menuItem.Visible = False
menuItem.Visible = True
Application.ScreenUpdating = True