ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   remove a control from a worksheet (https://www.excelbanter.com/excel-programming/353935-remove-control-worksheet.html)

Joe

remove a control from a worksheet
 
This is the code I used to remove the control, I get runtime error 5 'invalid
procedure call or argument'. Here is the code I used to remove the control:
application.CommandBars("Worksheet Menu Bar").Controls("cmd").Delete

This is the code I used to Add the control:
Set cmd = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cmd
.BeginGroup = True
.Caption = "myControl"
.BeginGroup = True
.OnAction = "Insert Macro Name Here"
End With


Jim Thomlinson[_5_]

remove a control from a worksheet
 
Give this a try...

application.CommandBars("Worksheet Menu Bar").Controls("myControl").Delete
--
HTH...

Jim Thomlinson


"joe" wrote:

This is the code I used to remove the control, I get runtime error 5 'invalid
procedure call or argument'. Here is the code I used to remove the control:
application.CommandBars("Worksheet Menu Bar").Controls("cmd").Delete

This is the code I used to Add the control:
Set cmd = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cmd
.BeginGroup = True
.Caption = "myControl"
.BeginGroup = True
.OnAction = "Insert Macro Name Here"
End With



All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com