Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I tried to adapt J.Walkenbach code to add a menu item on Workbook_open
but I get the following error on "HelpIndex = CommandBars(1).Controls ("Help").Index" Run-time Error '91' Object variable or with block variable not set Private Sub Workbook_Open() Dim HelpIndex As Integer Dim NewMenu As CommandBarPopup ' Get Index of Help menu HelpIndex = CommandBars(1).Controls("Help").Index ' Create the control Set NewMenu = CommandBars(1) _ .Controls.Add(Type:=msoControlPopup, Befo=HelpIndex, Temporary:=True) ' Add a caption NewMenu.Caption = "Fi<er" End Sub Help appreciated, J.P. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you use a non English version it is possible that the Help label not exist
You can use the ID number of the control See http://www.rondebruin.nl/international.htm#Command -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "u473" wrote in message ... I tried to adapt J.Walkenbach code to add a menu item on Workbook_open but I get the following error on "HelpIndex = CommandBars(1).Controls ("Help").Index" Run-time Error '91' Object variable or with block variable not set Private Sub Workbook_Open() Dim HelpIndex As Integer Dim NewMenu As CommandBarPopup ' Get Index of Help menu HelpIndex = CommandBars(1).Controls("Help").Index ' Create the control Set NewMenu = CommandBars(1) _ .Controls.Add(Type:=msoControlPopup, Befo=HelpIndex, Temporary:=True) ' Add a caption NewMenu.Caption = "Fi<er" End Sub Help appreciated, J.P. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA:programmatically invoking menu items from Excel Worksheet menu | Excel Programming | |||
Adding a Custom menu / sub menu | Excel Programming | |||
Adding Sub Menu Item to Current Custom Menu | Excel Programming | |||
Adding a menu item right click menu when clicking on a single. | Excel Programming | |||
Adding menu to the mouse right click pop-up menu | Excel Programming |