PDA

View Full Version : automatically delet pictures



sls
08-01-2007, 08:41 AM
hallo,

In my worksheet, there are some pictures that I want to delete automatically.
But my problem is that the number of picture can be different every time in my worksheet, and the name of the pictures changes also, how can I solve this problem??

Example:

ActiveSheet.Shapes("Picture 21").Select
ActiveSheet.Shapes.Range(Array("Picture 21", "Picture 22")).Select
ActiveSheet.Shapes.Range(Array("Picture 21", "Picture 22", "Picture 23")). _
Select
Selection.Delete

The next time:
ActiveSheet.Shapes("Picture 24").Select
ActiveSheet.Shapes.Range(Array("Picture 24", "Picture 25")).Select

Selection.Delete

The problem is that you never know how many pictures there are in the worksheet.

With friendly greetings

sls

rory
08-01-2007, 08:59 AM
Try something like:
Dim lngIndex as Long
For lngIndex = Activesheet.shapes.Count to 1 Step -1
If left$(Activesheet.shapes(lngIndex).Name,7) = "Picture" Then Activesheet.shapes(lngindex).delete
Next lngindex

Regards,
Rory

Bob Phillips
08-01-2007, 09:00 AM
Sub Shapes1()
'Delete all Objects except Comments
On Error Resume Next
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub

sls
08-01-2007, 10:36 AM
thx for the help, it worked :)

one new happy user :)