View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
lostwings lostwings is offline
external usenet poster
 
Posts: 2
Default how to permantly delete a custom menu in excel

hi,

I met a very strange problem with Excel.

Firstly I created a custom menu using the following VBA snippet

Sub add_menu()
Dim cmd_Bar As CommandBar
Dim menu_Intranet As CommandBarControl
Set cmd_Bar = Application.CommandBars("Worksheet Menu Bar")
Set menu_Intranet = cmd_Bar.Controls.Add(Type:=10, Temporary:=True)
menu_Intranet.Caption = "Intranet Entry"
End Sub

Then a custom menu appeared on the run time. However, after I closed the
excel, and reopened it without running any VBA Code, the same menu appeared,
which is very surprising. Then I used the following code to programmtically
delete the menu,

Sub delete_menu()
Dim cmd_Bar As CommandBar
Dim menu_Intranet As CommandBarControl

Set cmd_Bar = Sheet1.Application.CommandBars("Worksheet Menu Bar")
For Each menu_Intranet In cmd_Bar.Controls
If menu_Intranet.Caption = "Intranet Entry" Then
menu_Intranet.Delete
End If
Next
End Sub

Although such code can delete the menu on the run time as expected, when I
close and reopne excel, the custom menu is still then.

I would greatly appreciate if anyboday can tell me how to persuade this
little baby to diappear permantly. Thanks in advance.


--
John 3:16