Object Delete

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.
 
D

Dave

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.
 
G

Gary''s Student

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.
 
S

Skinman

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.
 

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

Similar Threads

Drawn Objects Q 2
Deleting Objects Q 2
Delete object code 1
code breaks in macro 1
Image Control 1
Removing Objects 1
Speeding up a delete rows Macro 6
Excel Macro delete certail column's 1

Top