Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default New menu bar item

Hi all

I'm trying to get a new item in the Worksheet Menu Bar
with an Add Inn, originally it was going to be one item
and it worked fine...i got it to appear on the Tools Menu
and to react as I wanted... soon my fellow workmates came
up with a similar need so what I tried is to have an item
on the tools menu that is like a combo menu (i.e.
the "Protection" menu inside the "tools" menu, has 3
items) but i have not been able to get a combo item inside
the tools menu... this is my code for the normal extra
control in the tools menu:

Sub createmenu()

Dim NewItem As CommandBarButton
Dim XLMenu As String
Dim XLCB As String
Dim NewItemName As String

XLCB = "Worksheet Menu Bar"
XLMenu = "Tools"

NewItemName = "Tool name here!"

On Error Resume Next
Application.CommandBars(XLCB).Controls(XLMenu).Con trols
(NewItemName).Delete

Set NewItem = Application.CommandBars(XLCB).Controls
(XLMenu).Controls.Add
With NewItem
..Caption = NewItemName
..OnAction = "macro name here!"
..FaceId = 0
..BeginGroup = True
End With

End Sub

I would like this to be a dropdown combo from where now i
choose from several tools....

any help is greatly appreciated...

regards
JS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default New menu bar item

Juan,

Here is an example

Sub createmenu
Dim NewItem As CommandBarControl
Dim XLMenu As CommandBarControl
Dim XLCB As CommandBar
Dim NewItemName As String

Set XLCB = Application.CommandBars("Worksheet Menu Bar")
Set XLMenu = XLCB.Controls("Tools")

NewItemName = "my dd"

On Error Resume Next
XLMenu.Controls(NewItemName).Delete
On Error GoTo 0

Set NewItem = XLMenu.Controls.Add(Type:=msoControlDropdown,
temporary:=True)
With NewItem
.Caption = NewItemName
.OnAction = "macro name here!"
.BeginGroup = True
End With
With XLMenu.Controls(NewItemName)
.AddItem "Bob"
.AddItem "Lynne"
.AddItem "Amy"
.ListIndex = 1
End With
End Sub

--

HTH

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

"Juan" wrote in message
...
Hi all

I'm trying to get a new item in the Worksheet Menu Bar
with an Add Inn, originally it was going to be one item
and it worked fine...i got it to appear on the Tools Menu
and to react as I wanted... soon my fellow workmates came
up with a similar need so what I tried is to have an item
on the tools menu that is like a combo menu (i.e.
the "Protection" menu inside the "tools" menu, has 3
items) but i have not been able to get a combo item inside
the tools menu... this is my code for the normal extra
control in the tools menu:

Sub createmenu()

Dim NewItem As CommandBarButton
Dim XLMenu As String
Dim XLCB As String
Dim NewItemName As String

XLCB = "Worksheet Menu Bar"
XLMenu = "Tools"

NewItemName = "Tool name here!"

On Error Resume Next
Application.CommandBars(XLCB).Controls(XLMenu).Con trols
(NewItemName).Delete

Set NewItem = Application.CommandBars(XLCB).Controls
(XLMenu).Controls.Add
With NewItem
.Caption = NewItemName
.OnAction = "macro name here!"
.FaceId = 0
.BeginGroup = True
End With

End Sub

I would like this to be a dropdown combo from where now i
choose from several tools....

any help is greatly appreciated...

regards
JS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default New menu bar item

Bob... thanks!! worked great...

JS



-----Original Message-----
Juan,

Here is an example

Sub createmenu
Dim NewItem As CommandBarControl
Dim XLMenu As CommandBarControl
Dim XLCB As CommandBar
Dim NewItemName As String

Set XLCB = Application.CommandBars("Worksheet Menu

Bar")
Set XLMenu = XLCB.Controls("Tools")

NewItemName = "my dd"

On Error Resume Next
XLMenu.Controls(NewItemName).Delete
On Error GoTo 0

Set NewItem = XLMenu.Controls.Add

(Type:=msoControlDropdown,
temporary:=True)
With NewItem
.Caption = NewItemName
.OnAction = "macro name here!"
.BeginGroup = True
End With
With XLMenu.Controls(NewItemName)
.AddItem "Bob"
.AddItem "Lynne"
.AddItem "Amy"
.ListIndex = 1
End With
End Sub

--

HTH

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

"Juan" wrote in message
...
Hi all

I'm trying to get a new item in the Worksheet Menu Bar
with an Add Inn, originally it was going to be one item
and it worked fine...i got it to appear on the Tools

Menu
and to react as I wanted... soon my fellow workmates

came
up with a similar need so what I tried is to have an

item
on the tools menu that is like a combo menu (i.e.
the "Protection" menu inside the "tools" menu, has 3
items) but i have not been able to get a combo item

inside
the tools menu... this is my code for the normal extra
control in the tools menu:

Sub createmenu()

Dim NewItem As CommandBarButton
Dim XLMenu As String
Dim XLCB As String
Dim NewItemName As String

XLCB = "Worksheet Menu Bar"
XLMenu = "Tools"

NewItemName = "Tool name here!"

On Error Resume Next
Application.CommandBars(XLCB).Controls(XLMenu).Con trols
(NewItemName).Delete

Set NewItem = Application.CommandBars(XLCB).Controls
(XLMenu).Controls.Add
With NewItem
.Caption = NewItemName
.OnAction = "macro name here!"
.FaceId = 0
.BeginGroup = True
End With

End Sub

I would like this to be a dropdown combo from where

now i
choose from several tools....

any help is greatly appreciated...

regards
JS



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default New menu bar item

My pleasure Juan.

--

HTH

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

"Juan" wrote in message
...
Bob... thanks!! worked great...

JS



-----Original Message-----
Juan,

Here is an example

Sub createmenu
Dim NewItem As CommandBarControl
Dim XLMenu As CommandBarControl
Dim XLCB As CommandBar
Dim NewItemName As String

Set XLCB = Application.CommandBars("Worksheet Menu

Bar")
Set XLMenu = XLCB.Controls("Tools")

NewItemName = "my dd"

On Error Resume Next
XLMenu.Controls(NewItemName).Delete
On Error GoTo 0

Set NewItem = XLMenu.Controls.Add

(Type:=msoControlDropdown,
temporary:=True)
With NewItem
.Caption = NewItemName
.OnAction = "macro name here!"
.BeginGroup = True
End With
With XLMenu.Controls(NewItemName)
.AddItem "Bob"
.AddItem "Lynne"
.AddItem "Amy"
.ListIndex = 1
End With
End Sub

--

HTH

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

"Juan" wrote in message
...
Hi all

I'm trying to get a new item in the Worksheet Menu Bar
with an Add Inn, originally it was going to be one item
and it worked fine...i got it to appear on the Tools

Menu
and to react as I wanted... soon my fellow workmates

came
up with a similar need so what I tried is to have an

item
on the tools menu that is like a combo menu (i.e.
the "Protection" menu inside the "tools" menu, has 3
items) but i have not been able to get a combo item

inside
the tools menu... this is my code for the normal extra
control in the tools menu:

Sub createmenu()

Dim NewItem As CommandBarButton
Dim XLMenu As String
Dim XLCB As String
Dim NewItemName As String

XLCB = "Worksheet Menu Bar"
XLMenu = "Tools"

NewItemName = "Tool name here!"

On Error Resume Next
Application.CommandBars(XLCB).Controls(XLMenu).Con trols
(NewItemName).Delete

Set NewItem = Application.CommandBars(XLCB).Controls
(XLMenu).Controls.Add
With NewItem
.Caption = NewItemName
.OnAction = "macro name here!"
.FaceId = 0
.BeginGroup = True
End With

End Sub

I would like this to be a dropdown combo from where

now i
choose from several tools....

any help is greatly appreciated...

regards
JS



.



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
Menu item disabled steven Excel Worksheet Functions 3 July 28th 06 12:59 AM
keep new menu item with workbook Andy G. Excel Discussion (Misc queries) 1 May 16th 06 08:09 PM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM
Customer menu Item Todd Huttenstine[_3_] Excel Programming 3 April 30th 04 12:31 AM
Access menu item from VBS elidag Excel Programming 1 November 13th 03 04:22 PM


All times are GMT +1. The time now is 02:10 AM.

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

About Us

"It's about Microsoft Excel"