View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Adding a new menu on the Worksheet menu bar

This basic test is working for me

Sub MenuBar_Item()
Call MenuBar_Item_Delete
With Application.CommandBars(1)
With .Controls.Add(Type:=msoControlButton, befo=Application.CommandBars.FindControl(, 30010).Index)
.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

Sub TestMacro()
MsgBox "Hi"
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"u473" wrote in message ...
"Help" ID is 30010
I tried to replace
HelpIndex = CommandBars(1).Controls("Help").Index
with
HelpIndex = CommandBars(1).Controls(ID:=30010).Index
I does not work.
I am working with a US Version of Excel 2003
and the original code comes from
Excel VBA Programming for Dummies from J. Walkenbach, page 314.
Where did I go wrong ?
Thank you for your response.
J.P.