LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Custom menu

Hi all,

I have a problem with my custom menu. I would like to have several levels of
the menu with sub menus. Unfortunately, I don't get back to the top-level.

Example:
1
1.1
1.2
2
3

Instead of:
1
1.1
1.2
2
3

I guess I need to include some code between:

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "German"
.FaceId = 420
.OnAction = "TheFinancialServiceProvidersChartG"
End With

' and this set of code

Set cbcCutomMenu = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu.Caption = "Return Analysis"

to come back to the first level. Otherwise I can only add menu links on the
same level.

Please find below the whole code. I would like to have "Return Analysis" on
the same level as the "The Financial Service Providers".

Can anybody help?

Kind regards,

Simon Minder




VBAProject
----------------------------------------------
Microsoft Excel Objekcts - ThisWorkbook
----------------------------------------------
Option Explicit

Private Sub Workbook_Activate()
Run "AddMenus"
End Sub

Private Sub Workbook_Deactivate()
Run "DeleteMenu"
End Sub

-----------------------------------
Modules - CommandBarMacro
-----------------------------------
Option Explicit

Sub AddMenus()
Dim cMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCutomMenu As CommandBarControl
Dim I As Integer
Dim sBar As String


'(1)Delete any existing one. We must use On Error Resume next in case it
does not exist.
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("MFO").Delete
On Error GoTo 0

'(2)Set a CommandBar variable to Worksheet menu bar
For I = 1 To 2
sBar = IIf(I = 1, "Worksheet Menu Bar", "Chart Menu Bar")
Set cbMainMenuBar = Application.CommandBars(sBar)

'(3)Return the Index number of the Help menu. We can then use this
to place a custom menu before.
iHelpMenu = cbMainMenuBar.Controls("Help").Index

'(4)Add a Control to the "Worksheet Menu Bar" before Help. Set a
CommandBarControl variable to it
Set cbcCutomMenu = cbMainMenuBar.Controls.Add(Type:=msoControlPopup,
Befo=iHelpMenu)

'5)Give the control a caption
cbcCutomMenu.Caption = "MFO"

'Add another menu that will lead off to another menu. Set a
CommandBarControl variable to it
Set cbcCutomMenu = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)

'Give the control a caption
cbcCutomMenu.Caption = "The Financial Service Providers"

'Add a contol to the sub menu, just created above
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Data"
.FaceId = 420
.OnAction = "TheFinancialServiceProvidersData"
End With

Set cbcCutomMenu = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu.Caption = "Chart"

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "English"
.FaceId = 420
.OnAction = "TheFinancialServiceProvidersChartE"
End With

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "German"
.FaceId = 420
.OnAction = "TheFinancialServiceProvidersChartG"
End With

Set cbcCutomMenu = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu.Caption = "Return Analysis"



Next

End Sub

Sub DeleteMenu()

On Error Resume Next

Application.CommandBars("Worksheet Menu Bar").Controls("MFO").Delete
Application.CommandBars("Chart Menu Bar").Controls("MFO").Delete

On Error GoTo 0

End Sub

-------------------------------
Modules - OnActionMacros
-------------------------------
Option Explicit
Sub TheFinancialServiceProvidersData()
Sheets("The Financial Service Providers").Select
End Sub
Sub TheFinancialServiceProvidersChartE()
Sheets("The Financial Ser. Pro. Graph E").Select
End Sub
Sub TheFinancialServiceProvidersChartG()
Sheets("The Financial Ser. Pro. Graph G").Select
End Sub




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom menu winqan Excel Discussion (Misc queries) 1 February 6th 06 10:51 AM
VBA - Disappearing custom menu and custom toolbar Peter[_50_] Excel Programming 2 December 2nd 04 06:09 PM
Custom Menu return to Excel Menu upon Closing VetcalcReport Excel Programming 2 August 2nd 04 02:59 PM
Custom Menu Luis Excel Programming 1 December 12th 03 01:54 PM
Custom Menu ewize1 Excel Programming 2 October 30th 03 05:16 PM


All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"