Object Delete

  • Thread starter Thread starter Skinman
  • Start date Start date
S

Skinman

Hi all! Wishing for some code help or to point me in the right direction.
Using excel 2007
When downloading a web page for the data it contains, it also downloads
unwanted pictures
I have this code in a Sub to get rid of the pictures.
my problem is it also deletes my macro buttons that I need to keep.

ActiveSheet.DrawingObjects.Select
Selection.Delete

Need to code to keep macro buttons but still delete all pictures?
Skinman.
 
Hi,
Something like:
For each DObj in DrawingObjects
If DrawingObject.Name <> YourButton1 Or _
DrawingObject.Name <> YourButton2 Or _
DrawingObject.Name <> YourButton3 Or Then A = DObj.Name
DObj(A).Delete
End If
Next DObj

Substitute your button names, and add as many more as you have.

Regards - Dave.
 
Sub pickiler()
Dim p
For Each p In ActiveSheet.Pictures
If Left(p.Name, 7) = "Command" Then
Else
p.Delete
End If
Next
End Sub


Note this saves Controls buttons. Forms buttons are not considered Pictures
by Excel, so they are already safe.
 
Thanks to everyone,
I am going to explore all answers to help me learn.
So far have used Gary's Student answer with success.
Many thanks. Skinman.
 
Back
Top