ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't Exit Design Mode because CommandButton2 cannot be created (https://www.excelbanter.com/excel-programming/322930-cant-exit-design-mode-because-commandbutton2-cannot-created.html)

Johnny Fugazzi

Can't Exit Design Mode because CommandButton2 cannot be created
 
I am having problems with an excel workbook that was working fine
previously.
The sheet is quite large and has a couple of command buttons on it to
trigger macros. I removed one of these buttons yesterday and saved the
file.

The worksheet now gives me an error whenever I move the mouse over one of
the buttons that remain. The error is "Can't Exit Design Mode because
CommandButton2 cannot be created".

It appears that the CommandButton2 is still resident in my workbook
somewhere, or is referenced in the code. I have looked through the VBA
code and I do not see it anywhere, but it does show up in the object
dropdown list at the top of the VB editior.

Can someone please help me to clear out this residue?


Thanks in advance



Tom Ogilvy

Can't Exit Design Mode because CommandButton2 cannot be created
 
for each obj in Activesheet.OleObjects
if typeof obj.Object is MSForms.Commandbutton
msgbox obj.Name
End if
next

if it finds it

for each obj in Activesheet.OleObjects
if typeof obj.Object is MSForms.Commandbutton
if lcase(obj.name) = "commandbutton2" then
obj.delete
end if
End if
next

--
Regards,
Tom Ogilvy

"Johnny Fugazzi" wrote in message
...
I am having problems with an excel workbook that was working fine
previously.
The sheet is quite large and has a couple of command buttons on it to
trigger macros. I removed one of these buttons yesterday and saved the
file.

The worksheet now gives me an error whenever I move the mouse over one of
the buttons that remain. The error is "Can't Exit Design Mode because
CommandButton2 cannot be created".

It appears that the CommandButton2 is still resident in my workbook
somewhere, or is referenced in the code. I have looked through the VBA
code and I do not see it anywhere, but it does show up in the object
dropdown list at the top of the VB editior.

Can someone please help me to clear out this residue?


Thanks in advance






All times are GMT +1. The time now is 05:38 PM.

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