![]() |
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 |
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 |
All times are GMT +1. The time now is 08:56 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com