#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Menus in xlmenubar

Sub Macro1()
MenuBars(xlWorksheet).Menus.Add Caption:="&Name1", befo="&Help"
With MenuBars(xlWorksheet).Menus("&Extras").MenuItems
.Add Caption:="Name1", OnAction:="Macro2"
.AddMenu Caption:="menu1"
End With
End Sub


how do i add a new caption to menu1 and also the onaction
could anyone please help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 834
Default Menus in xlmenubar

Use commandbatrs

Dim idx As Long

On Error Resume Next
Application.CommandBars(1).Controls("&Name1").Dele te
On Error GoTo 0

idx = Application.CommandBars.FindControl(ID:=30010).Ind ex
With Application.CommandBars(1).Controls.Add(Type:=msoC ontrolPopup,
befo=idx)

.Caption = "&Name1"

With .Controls.Add(Type:=msoControlButton)

.Caption = "menu1"
.OnAction = "Test"
End With
End With


--

HTH

Bob

"Steve davis" <Steve wrote in message
...
Sub Macro1()
MenuBars(xlWorksheet).Menus.Add Caption:="&Name1", befo="&Help"
With MenuBars(xlWorksheet).Menus("&Extras").MenuItems
.Add Caption:="Name1", OnAction:="Macro2"
.AddMenu Caption:="menu1"
End With
End Sub


how do i add a new caption to menu1 and also the onaction
could anyone please help



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Menus in xlmenubar


hi when this sheet opens up the first thing it has to do is wipe out file to
help to limit the amout of damage users of the sheet can do to it all this
works fine
i then remake a complete new set of menus all this works fine but when i put
a submenu in my menu i cant add to it
like in excel click view then toolbars
but cant add to the toolbars menu
"Bob Phillips" wrote:

Use commandbatrs

Dim idx As Long

On Error Resume Next
Application.CommandBars(1).Controls("&Name1").Dele te
On Error GoTo 0

idx = Application.CommandBars.FindControl(ID:=30010).Ind ex
With Application.CommandBars(1).Controls.Add(Type:=msoC ontrolPopup,
befo=idx)

.Caption = "&Name1"

With .Controls.Add(Type:=msoControlButton)

.Caption = "menu1"
.OnAction = "Test"
End With
End With


--

HTH

Bob

"Steve davis" <Steve wrote in message
...
Sub Macro1()
MenuBars(xlWorksheet).Menus.Add Caption:="&Name1", befo="&Help"
With MenuBars(xlWorksheet).Menus("&Extras").MenuItems
.Add Caption:="Name1", OnAction:="Macro2"
.AddMenu Caption:="menu1"
End With
End Sub


how do i add a new caption to menu1 and also the onaction
could anyone please help



.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Menus in xlmenubar


hi thanks 4 the help had a play a first with no success but got it ight
later this is the new one


Dim idx As Long

idx = Application.CommandBars.FindControl(ID:=30010).Ind ex
With Application.CommandBars(1).Controls.Add(Type:=msoC ontrolPopup,
befo=idx)

.Caption = "&Menu1"

With .Controls.Add(Type:=msoControlButton)
.Caption = "name1"
.OnAction = "Test"

End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "name2"
.OnAction = "Test"

End With

With .Controls.Add(Type:=msoControlPopup)
.Caption = "menu2"

With .Controls.Add(Type:=msoControlButton)
.Caption = "name3"
.OnAction = "Test"
End With
End With
End With
End Sub


with the old xlmenubar option i could add more than one caption between my
end with command.
but when i put name1 and name2 in the same end with only name2 was showing
so did it this way thanks 4 your help its put me on the right track now


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 834
Default Menus in xlmenubar

You have got the right way to nest the menus. I would just suggest better
indentation to make it more readable

Dim idx As Long

idx = Application.CommandBars.FindControl(ID:=30010).Ind ex
With Application.CommandBars(1).Controls.Add( _
Type:=msoControlPopup, _
befo=idx)

.Caption = "&Menu1"

With .Controls.Add(Type:=msoControlButton)

.Caption = "name1"
.OnAction = "Test"
End With

With .Controls.Add(Type:=msoControlButton)

.Caption = "name2"
.OnAction = "Test"
End With

With .Controls.Add(Type:=msoControlPopup)

.Caption = "menu2"

With .Controls.Add(Type:=msoControlButton)

.Caption = "name3"
.OnAction = "Test"
End With
End With
End With

--

HTH

Bob

"Steve davis" wrote in message
...

hi thanks 4 the help had a play a first with no success but got it ight
later this is the new one


Dim idx As Long

idx = Application.CommandBars.FindControl(ID:=30010).Ind ex
With Application.CommandBars(1).Controls.Add(Type:=msoC ontrolPopup,
befo=idx)

.Caption = "&Menu1"

With .Controls.Add(Type:=msoControlButton)
.Caption = "name1"
.OnAction = "Test"

End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "name2"
.OnAction = "Test"

End With

With .Controls.Add(Type:=msoControlPopup)
.Caption = "menu2"

With .Controls.Add(Type:=msoControlButton)
.Caption = "name3"
.OnAction = "Test"
End With
End With
End With
End Sub


with the old xlmenubar option i could add more than one caption between my
end with command.
but when i put name1 and name2 in the same end with only name2 was showing
so did it this way thanks 4 your help its put me on the right track now






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Menus in xlmenubar


hi thanks again for help will us text ie

' this bit has this

' that bit has that

and also try to put all my T's & R's in missing from last message
Reply
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
Sub-menus of main menus for Excel 2007 Eleanor Peppard New Users to Excel 1 March 16th 10 04:12 PM
Creating Drop-down menus with subset drop-down menus Benjamin Excel Worksheet Functions 4 June 8th 09 11:27 PM
Menus Teddytim1 Excel Discussion (Misc queries) 1 February 25th 09 03:02 PM
difference between word 2003 menus and word 2007 menus-Explain pl kali Excel Discussion (Misc queries) 1 August 29th 07 07:56 AM
New Menus - attaching but menus are reset Greegan Excel Worksheet Functions 0 November 5th 05 03:19 PM


All times are GMT +1. The time now is 11:24 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"