View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_538_] Simon Lloyd[_538_] is offline
external usenet poster
 
Posts: 1
Default How to reset Worksheet Menu Bar in VBA???

I have this code which creates a button on the worksheet menu bar but i
isnt deleted when i run my autoclose program thats why i wantes to rese
the menu bar, if either of you know of a nicer way to manage this rathe
than be aggressive and put everything back to normal please let m
know.

Simon.

Here's the code!

Sub en()
Dim c As Variant
On Error Resume Next
With Application
.CommandBars.ActiveMenuBar.Enabled = True
For Each c In .CommandBars("Worksheet menu Bar").Controls
If c.Caption = "EN" Then c.Delete
Next c
Set cb = .CommandBars("Worksheet Men
Bar").Controls.Add(Type:=msoControlButton, Id:=2950, befo=1)
cb.Caption = "EN"
cb.TooltipText = "Enable Events"
cb.OnAction = ThisWorkbook.Name & "!enevents"
cb.Style = msoButtonCaption
Worksheets("hidden").Visible = True

End With
End Sub

Sub enevents()
Application.EnableEvents = Not Application.EnableEvents
End Su

--
Message posted from http://www.ExcelForum.com