Do you mean you want to have your addin create a new menu? Here's some
sample code
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("myMenu").Delete
On Error GoTo 0
End Sub
Private Sub Workbook_Open()
Dim oCB As CommandBar
Dim oCBCtl As CommandBarControl
Dim HelpMenu As CommandBarControl
Dim MainMenu As CommandBarPopup
Dim MenuItem As CommandBarControl
Dim Submenuitem As CommandBarButton
' Deletes menu if it exits
On Error Resume Next
Application.CommandBars("myMenu").Delete
On Error GoTo 0
Set oCB = Application.CommandBars("Worksheet Menu Bar")
' Find the help menu
Set HelpMenu = oCB.FindControl(ID:=30010)
If HelpMenu Is Nothing Then
' Add the menu to the end
Set oCBCtl = oCB.Controls. _
Add(Type:=msoControlPopup, temporary:=True)
Else
' Add menu before help
Set oCBCtl = oCB.Controls. _
Add(Type:=msoControlPopup, before:=HelpMenu.Index, _
temporary:=True)
End If
With oCBCtl
.Caption = "myMenu"
With oCBCtl
With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "Set Defaults"
.FaceId = 23
.Style = msoButtonCaption
.OnAction = "ShowQDEForm"
End With
With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "QDE Help"
.FaceId = 23
.Style = msoButtonCaption
.OnAction = "ShowQDEHelp"
End With
With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "About"
.FaceId = 23
.Style = msoButtonCaption
.OnAction = "ShowQDEABout"
End With
End With
End With
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
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.