Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How do I delete my custom button on closing

Hello everyone

I use the following code to create a button and run a macro - the problem is
how do I delete it when I close the workbook

Any Ideas

Kenny

I am using

Sub MyButton()
Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(Type:= _
msoControlButton)
With MenuItem
.FaceId = 277
.OnAction = "MyPass"
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How do I delete my custom button on closing

Hi Kenny,

Change:

Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(Type:= _
msoControlButton)


to

Set MenuItem = Application.CommandBars("Worksheet Menu Bar") _
.Controls.Add(Type:=msoControlButton, Temporary:=True)

Temporary controls are automatically deleted when Excel is closed.

---
Regards,
Norman



"N E Body" wrote in message
...
Hello everyone

I use the following code to create a button and run a macro - the problem
is
how do I delete it when I close the workbook

Any Ideas

Kenny

I am using

Sub MyButton()
Set MenuItem = Application.CommandBars("Worksheet Menu
Bar").Controls.Add(Type:= _
msoControlButton)
With MenuItem
.FaceId = 277
.OnAction = "MyPass"
End With
End Sub




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
2003 - 2007 custom macro and custom button restore. Scott Sornberger Excel Discussion (Misc queries) 11 May 23rd 08 02:41 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
Can't delete custom button and toolbar Ron de Bruin Excel Programming 1 March 1st 04 09:46 PM
Closing a workbook by a button only Libby-xl97 Excel Programming 2 November 11th 03 01:10 AM


All times are GMT +1. The time now is 08:40 PM.

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"