Article ID: 161926
Article Last Modified on 11/23/2006
Sub checked_menuitem()
'add a new docked CommandBar
Set mybar = CommandBars.Add(Name:="my command bar", _
Position:=msoBarTop)
mybar.Visible = True
'add a menu to the custom CommandBar
Set mypopup = mybar.Controls.Add(Type:=msoControlPopup)
mypopup.Caption = "my menu"
'add a menu item to the menu just added to the CommandBar
Set myitem = mypopup.Controls.Add(Type:=msoControlButton)
myitem.Caption = "my menu item"
myitem.OnAction = "check_item"
End Sub
Sub check_item()
Set mypopup = CommandBars("my command bar").Controls("my menu")
If mypopup.Controls("my menu item").State = msoButtonDown Then
'remove check next to menu item
mypopup.Controls("my menu item").State = msoButtonUp
MsgBox "menu item is now unchecked"
Else
'add check next to menu item
mypopup.Controls("my menu item").State = msoButtonDown
MsgBox "menu item is now checked"
End If
End Sub
Additional query words: 97 XL97
Keywords: kbdtacode kbprogramming kbualink97 KB161926