ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   requirement for creating a sub menu in c# excel addin (https://www.excelbanter.com/excel-programming/388459-requirement-creating-sub-menu-c-excel-addin.html)

shantanu

requirement for creating a sub menu in c# excel addin
 
Dear All
I have a requirement for creating a sub menu. I have been
working on the addin and was able to put the addin in the tools menu
of excel. The menu will be something like:

1. Main Item
1.a. Sub item 1
1.a.i sub item 1
1.a.ii sub item 2
1.b. Sub item 1
1.b.i sub item 1
1.b.ii sub item 2

Can anybody help in creating this kind of menu formation in excel from
C# addin.

Regards
shantanu


Bob Phillips

requirement for creating a sub menu in c# excel addin
 
Here is an example

Sub MultiLevelMenus()
Dim oCb As CommandBar
Dim oCtl1 As CommandBarPopup
Dim oCtl2 As CommandBarPopup
Dim oCtl3 As CommandBarPopup
Dim oCtlBtn As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl1 = .Controls("Tools").Controls.Add( _
Type:=msoControlPopup, _
temporary:=True)
oCtl1.Caption = "Level1"
With oCtl1
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton)
oCtlBtn.Caption = "Level1 Button1"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myLevel1Button1Macro"
With oCtl1
Set oCtl2 = .Controls.Add( _
Type:=msoControlPopup)
oCtl2.Caption = "Level2"
With oCtl2
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton)
oCtlBtn.Caption = "Level2 Button1"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myLevel2Button1Macro"
Set oCtl3 = .Controls.Add( _
Type:=msoControlPopup)
oCtl3.Caption = "Level3"
With oCtl3
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton)
oCtlBtn.Caption = "Level3 Button1"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myLevel3Button1Macro"
End With
End With
End With
'etc.
End With
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"shantanu" wrote in message
oups.com...
Dear All
I have a requirement for creating a sub menu. I have been
working on the addin and was able to put the addin in the tools menu
of excel. The menu will be something like:

1. Main Item
1.a. Sub item 1
1.a.i sub item 1
1.a.ii sub item 2
1.b. Sub item 1
1.b.i sub item 1
1.b.ii sub item 2

Can anybody help in creating this kind of menu formation in excel from
C# addin.

Regards
shantanu




shantanu

requirement for creating a sub menu in c# excel addin
 
On May 1, 12:18 pm, "Bob Phillips" wrote:
Here is an example

Sub MultiLevelMenus()
Dim oCb As CommandBar
Dim oCtl1 As CommandBarPopup
Dim oCtl2 As CommandBarPopup
Dim oCtl3 As CommandBarPopup
Dim oCtlBtn As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl1 = .Controls("Tools").Controls.Add( _
Type:=msoControlPopup, _
temporary:=True)
oCtl1.Caption = "Level1"
With oCtl1
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton)
oCtlBtn.Caption = "Level1 Button1"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myLevel1Button1Macro"
With oCtl1
Set oCtl2 = .Controls.Add( _
Type:=msoControlPopup)
oCtl2.Caption = "Level2"
With oCtl2
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton)
oCtlBtn.Caption = "Level2 Button1"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myLevel2Button1Macro"
Set oCtl3 = .Controls.Add( _
Type:=msoControlPopup)
oCtl3.Caption = "Level3"
With oCtl3
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton)
oCtlBtn.Caption = "Level3 Button1"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myLevel3Button1Macro"
End With
End With
End With
'etc.
End With
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"shantanu" wrote in message

oups.com...



Dear All
I have a requirement for creating a sub menu. I have been
working on the addin and was able to put the addin in the tools menu
of excel. The menu will be something like:


1. Main Item
1.a. Sub item 1
1.a.i sub item 1
1.a.ii sub item 2
1.b. Sub item 1
1.b.i sub item 1
1.b.ii sub item 2


Can anybody help in creating this kind of menu formation in excel from
C# addin.


Regards
shantanu- Hide quoted text -


- Show quoted text -


thanx for the code but can u get me in C# as i am not familiar with vb
reagrds
shantanu



All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com