Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting new control button on auto_close??

I have some code which creates a menu bar item to disable/enable events,
how do i delete this item on Auto_close?
Do i say For Each c In .Captions
If c.Caption = "EN" Then Delete
Next

Would that do it?

Simon.

Heres the code i use to create the menu item......

Dim c As Variant
On Error Resume Next
With Application.CommandBars("Worksheet Menu Bar")
For Each c In .Controls
If c.Caption = "EN" Then c.Delete
Next c
..Controls.Add Type:=msoControlButton, ID:=2950, Befo=1
..Controls(1).Caption = "EN"
..Controls(1).TooltipText = "Enable Events"
..Controls(1).OnAction = ThisWorkbook.Name & "!enevents"
..Controls(1).Style = msoButtonCaption
End With
End Sub
--------------------



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


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Deleting new control button on auto_close??

One way:

With Application.CommandBars("Worksheet Menu Bar")
On Error Resume Next
.Controls("EN").Delete
On Error GoTo 0
With .Controls.Add(Type:=msoControlButton, _
Id:=2950, Befo=1)
.Caption = "EN"
.TooltipText = "EnableEvents"
.OnAction = ThisWorkbook.Name & "!enevents"
.Style = msoButtonCaption
End With
End With




In article ,
Simon Lloyd wrote:

I have some code which creates a menu bar item to disable/enable events,
how do i delete this item on Auto_close?
Do i say For Each c In .Captions
If c.Caption = "EN" Then Delete
Next

Would that do it?

Simon.

Heres the code i use to create the menu item......

Dim c As Variant
On Error Resume Next
With Application.CommandBars("Worksheet Menu Bar")
For Each c In .Controls
If c.Caption = "EN" Then c.Delete
Next c
.Controls.Add Type:=msoControlButton, ID:=2950, Befo=1
.Controls(1).Caption = "EN"
.Controls(1).TooltipText = "Enable Events"
.Controls(1).OnAction = ThisWorkbook.Name & "!enevents"
.Controls(1).Style = msoButtonCaption
End With
End Sub
--------------------



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


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

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
deleting check control box Brad Excel Discussion (Misc queries) 1 September 29th 05 08:21 PM
Deleting a textbox control at runtime Grant Williams Excel Programming 3 June 14th 04 08:33 AM
Deleting unwated control characters at the end in a particular column ssexcel[_7_] Excel Programming 4 November 15th 03 03:34 AM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"