menu question


B

bill

How can I create a sub menu under the menu item 'Comments'?

tia

Set MenuItem = NewMenu.Controls.Add (Type:=msoControlPopup)
With MenuItem
.Caption = "&Comments"
.BeginGroup = True
End With

Set Submenuitem = MenuItem.Controls.Add (Type:=msoControlButton)
With Submenuitem
.Caption = "&Display Comments"
.OnAction = " ShowTheComments"
End With
 
Ad

Advertisements

B

Bernie Deitrick

Bill,

The code you included does just that, though you haven't set the NewMenu object up. If you need more complete code, then see below.

HTH,
Bernie
Excel MVP

Sub MakeBill()
Dim NewMenu As CommandBar
Dim MenuItem As CommandBarControl
Dim SubMenuItem As CommandBarControl

On Error Resume Next
Application.CommandBars("Bill").Delete

Set NewMenu = Application.CommandBars.Add("Bill")
With NewMenu
.Visible = True
.Position = msoBarFloating
End With

Set MenuItem = NewMenu.Controls.Add(Type:=msoControlPopup)
With MenuItem
.Caption = "&Comments"
.BeginGroup = True
End With

Set SubMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
With SubMenuItem
.Caption = "&Display Comments"
.OnAction = " ShowTheComments"
End With
End Sub
 

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