Sub Menu Items

P

pauluk

Hi all,

I need a bit of help. Does anyone now how to places items into a su
menu

the menu code is below and i would like to know how to place items i
the project codes menu

==============================================
Dim CMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCustomMenu As CommandBarControl

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("CC
Generator").Delete
On Error GoTo 0
'
' Point to the Worksheet Menu Bar
'
Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar")
'
' Set Before Help menu
'
iHelpMenu = cbMainMenuBar.Controls("Help").Index
'
' Add new menu
'
Set cbcCustomMenu = cbMainMenuBar.Controls. _
Add(Type:=msoControlPopup, Before:=iHelpMenu)
'
' Name New Menu
'
cbcCustomMenu.Caption = "CCC Generator"
'
' Add Sub Menus
'
With cbcCustomMenu.Controls.Add(Type:=msoControlPopup)
.Caption = "Project Codes"
.Tag = "Project Codes"
End With

==============================================

Thanks
Pau
 
B

Bob Phillips

Paul,

Here is an example

Dim CMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCustomMenu As CommandBarControl

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("CCC
Generator").Delete
On Error GoTo 0
'
' Point to the Worksheet Menu Bar
'
Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar")
'
' Set Before Help menu
'
iHelpMenu = cbMainMenuBar.Controls("Help").Index
'
' Add new menu
'
Set cbcCustomMenu = cbMainMenuBar.Controls. _
Add(Type:=msoControlPopup, Before:=iHelpMenu, temporary:=True)
'
' Name New Menu
'
cbcCustomMenu.Caption = "CCC Generator"
'
' Add Sub Menus
'
With cbcCustomMenu.Controls.Add(Type:=msoControlPopup)
.Caption = "Project Codes"
.Tag = "Project Codes"
Set CMenu1 = .Controls.Add(Type:=msoControlButton)
With CMenu1
.Caption = "&Sub_Menu1"
.FaceId = 48
.OnAction = "myMacro1"
End With

Set CMenu1 = .Controls.Add(Type:=msoControlButton)
With CMenu1
.Caption = "&Sub_Menu2"
.FaceId = 49
.OnAction = "myMacro2"
End With
End With



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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