ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   msoControlButton to "Worksheet Menu Bar" ? (https://www.excelbanter.com/excel-programming/353076-msocontrolbutton-worksheet-menu-bar.html)

Soniya[_4_]

msoControlButton to "Worksheet Menu Bar" ?
 
Hi All,

I find it easy to add an msoControlPopup menu item to "Worksheet Menu
Bar"

Is it possible to add msoControlButton to "Worksheet Menu Bar" ?

when I tried to get it does,nt work !?

Thanks


Ron de Bruin

msoControlButton to "Worksheet Menu Bar" ?
 
Hi Soniya

Do you want this

Sub MenuBar_Item()
MenuBar_Item_Delete
With Application.CommandBars(1)
With .Controls.Add(Type:=msoControlButton, befo=1)
.Style = msoButtonCaption
.Caption = "&Hi"
.OnAction = ThisWorkbook.Name & "!TestMacro"
End With
End With
End Sub

Sub MenuBar_Item_Delete()
On Error Resume Next
Application.CommandBars(1).Controls("Hi").Delete
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Soniya" wrote in message ups.com...
Hi All,

I find it easy to add an msoControlPopup menu item to "Worksheet Menu
Bar"

Is it possible to add msoControlButton to "Worksheet Menu Bar" ?

when I tried to get it does,nt work !?

Thanks




Bob Phillips[_6_]

msoControlButton to "Worksheet Menu Bar" ?
 
Soniya,

This worked for me

With Application.CommandBars("Worksheet Menu Bar")
With .Controls.Add(Type:=msoControlButton, temporary:=True)
.Caption = "Test"
.Style = msoButtonCaption
.OnAction = "myMacro"
End With
End With


Note setting the style, this is critical if you want to see the text <G

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Soniya" wrote in message
ups.com...
Hi All,

I find it easy to add an msoControlPopup menu item to "Worksheet Menu
Bar"

Is it possible to add msoControlButton to "Worksheet Menu Bar" ?

when I tried to get it does,nt work !?

Thanks




Soniya[_4_]

msoControlButton to "Worksheet Menu Bar" ?
 
thanks for your help.

Now it works !

i was missing the .style part



All times are GMT +1. The time now is 03:24 AM.

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