Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default 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
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
problem with custom menu Tony Excel Programming 4 May 3rd 05 02:27 PM
Custom Menu Jimbob Excel Programming 0 February 3rd 05 06:57 PM
VBA - Disappearing custom menu and custom toolbar Peter[_50_] Excel Programming 2 December 2nd 04 06:09 PM
Custom Menu return to Excel Menu upon Closing VetcalcReport Excel Programming 2 August 2nd 04 02:59 PM
Custom Menu ewize1 Excel Programming 2 October 30th 03 05:16 PM


All times are GMT +1. The time now is 03:36 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"