Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
MenuItem Check Mark
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="scott, post: 6256518"] I figured it out. Sub CreateMyMenu() On Error Resume Next Application.CommandBars("My Menu").Delete On Error GoTo 0 Dim HelpMenu As CommandBarControl, NewMenu As CommandBarPopup Dim MenuItem As CommandBarControl, SubMenuItem As CommandBarButton ' Delete the menu if it already exists Call RemoveMenu ' Find the Help Menu Set HelpMenu = CommandBars(1).FindControl(ID:=30010) If HelpMenu Is Nothing Then ' Add the menu to the end Set NewMenu = CommandBars(1).Controls.Add _ (Type:=msoControlPopup, _ temporary:=True) Else ' Add the menu before Help Set NewMenu = CommandBars(1).Controls.Add _ (Type:=msoControlPopup, _ Before:=HelpMenu.Index, _ temporary:=True) End If ' Add a caption for the menu NewMenu.Caption = "&My Menu" ' 1st main menu item Set MenuItem = NewMenu.Controls.Add _ (Type:=msoControlPopup) With MenuItem .Caption = "Options" .BeginGroup = True End With ' 1st submenu item Set SubMenuItem = MenuItem.Controls.Add _ (Type:=msoControlButton) With SubMenuItem .Caption = "&Option 1" .OnAction = "SetMenuItemChecked" End With ' 2nd submenu item Set SubMenuItem = MenuItem.Controls.Add _ (Type:=msoControlButton) With SubMenuItem .Caption = "Option 2" End With ' add a menu to restore the original menus Set MenuItem = NewMenu.Controls.Add _ (Type:=msoControlButton) With MenuItem .Caption = "Remove Menu" .OnAction = "RemoveMenu" .BeginGroup = True End With End Sub Sub SetMenuItemChecked() 'show or hide check mark for Protection If CommandBars("Worksheet menu bar").Controls("My Menu") _ .Controls("Options").Controls("Option 1").State = msoButtonDown Then CommandBars("Worksheet menu bar").Controls("My Menu") _ .Controls("Options").Controls("Option 1").State = msoButtonUp MsgBox "menu item is now unchecked" Else CommandBars("Worksheet menu bar").Controls("My Menu") _ .Controls("Options").Controls("Option 1").State = msoButtonDown MsgBox "menu item is now checked" End If End Sub Sub RemoveMenu() On Error Resume Next CommandBars(1).Controls("My Menu").Delete End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
MenuItem Check Mark
Top