View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
newbie newbie is offline
external usenet poster
 
Posts: 137
Default Identify and delete the specified objects names

I used the following code that allows me to identify and delete a specific
object in the worksheet via a user interface. The code works this morning but
don't know why, when or how, this Runtime Error 1004: Application or
object-defined error. appears at the line every time the program tries to
delete the object. Someone suggested me to use clean registry but I have not
really tried it yet. Is there a way to avoid this problem? I hope to find a
simple way that can perform the same function as the following code? Your
advice or help will be greatly appreciated.

Thanks.

Public Sub Deleteonstrfr()
Dim Obj As Object

For Each Obj In Sheets("SLD").Shapes
If Left(Obj.Name, 7) = "onstrfr" Then
Obj.Delete '***Run-time Error found at here'
End If
Next Obj

End Sub