Can't Exit Design Mode because CommandButton2 cannot be created

J

Johnny Fugazzi

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top