Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
problem with custom menu
I had to modify my custom menu. Originally adding and removing my custom
menus was done by the following code: ------------------------------------------------- Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = "My Macros" .DescriptionText = "Macros Menu" End With ---------------------------------------------------------- Sub RemoveMenus() On Error Resume Next ' Remove Menu Bar. CommandBars("Worksheet Menu Bar").Controls("My Macros").Delete End Sub ---------------------------------------------------------- Because I have to use special characters in the names of my custom menu, following the advice from this group I modified my code to: ---------------------------------------------------------- Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = Range("menu1") .DescriptionText = "Macros Menu" End With ---------------------------------------------------------- Now executing of the code is replacing before last menu item with my menu. What I am doing wrong ? How I have to modify my code so that my menu will add new menu, not replace one of the existing ones. How I need to modify the removing code so that my new menu will be removed when closing the workbook. Thanks for advice. Regards, Tony |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
problem with custom menu
I had a problem with uploading of my question. This is duplicated post.
Please ignore. Tony "Tony" wrote: I had to modify my custom menu. Originally adding and removing my custom menus was done by the following code: ------------------------------------------------- Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = "My Macros" .DescriptionText = "Macros Menu" End With ---------------------------------------------------------- Sub RemoveMenus() On Error Resume Next ' Remove Menu Bar. CommandBars("Worksheet Menu Bar").Controls("My Macros").Delete End Sub ---------------------------------------------------------- Because I have to use special characters in the names of my custom menu, following the advice from this group I modified my code to: ---------------------------------------------------------- Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = Range("menu1") .DescriptionText = "Macros Menu" End With ---------------------------------------------------------- Now executing of the code is replacing before last menu item with my menu. What I am doing wrong ? How I have to modify my code so that my menu will add new menu, not replace one of the existing ones. How I need to modify the removing code so that my new menu will be removed when closing the workbook. Thanks for advice. Regards, Tony |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
problem with custom menu
Sub RemoveMenus()
On Error Resume Next ' Remove Menu Bar. CommandBars("Worksheet Menu Bar").Controls(Range("menu1").Value).Delete End Sub Sub AddMenuBAr() Dim cmbMenu As CommandBarControl Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = Range("menu1") .DescriptionText = "Macros Menu" End With End Sub "Tony" wrote: I had to modify my custom menu. Originally adding and removing my custom menus was done by the following code: ------------------------------------------------- Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = "My Macros" .DescriptionText = "Macros Menu" End With ---------------------------------------------------------- Sub RemoveMenus() On Error Resume Next ' Remove Menu Bar. CommandBars("Worksheet Menu Bar").Controls("My Macros").Delete End Sub ---------------------------------------------------------- Because I have to use special characters in the names of my custom menu, following the advice from this group I modified my code to: ---------------------------------------------------------- Set cmbMenu = CommandBars("Worksheet Menu Bar"). _ Controls.Add(Type:=msoControlPopup, _ Befo=CommandBars("Worksheet Menu Bar") _ .Controls.Count) ' Set the caption of the new menu. With cmbMenu .Caption = Range("menu1") .DescriptionText = "Macros Menu" End With ---------------------------------------------------------- Now executing of the code is replacing before last menu item with my menu. What I am doing wrong ? How I have to modify my code so that my menu will add new menu, not replace one of the existing ones. How I need to modify the removing code so that my new menu will be removed when closing the workbook. Thanks for advice. Regards, Tony |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
problem with custom menu | Excel Programming | |||
Custom Menu | Excel Programming | |||
VBA - Disappearing custom menu and custom toolbar | Excel Programming | |||
Custom Menu return to Excel Menu upon Closing | Excel Programming | |||
Custom Menu | Excel Programming |