Sub Makro1()
ActiveWindow.Selection.SlideRange.Shapes("Picture 4").Select
ActiveWindow.Selection.ShapeRange.Delete
ActiveWindow.Selection.SlideRange.Shapes("Object 5").Select
ActiveWindow.Selection.ShapeRange.Delete
End Sub
this will remove picture 4 and object 5 in "a slide" but i want to do it in
all slides how can i do it?
John Wilson - 19 Dec 2007 11:11 GMT
That looks like code from the recorder? Not usually a good idea.
If it's at all possible never select shapes in vba and there's no need in
this case.
Is it "Picture 4" and "Object 5" on every slide?
Is so try this:
Sub zapem()
Dim osld As Slide
Dim oshp As Shape
Dim i As Integer
'cycle through all slides
For Each osld In ActivePresentation.Slides
'cycle through each shape in reverse order
For i = osld.Shapes.Count To 1 Step -1
Set oshp = osld.Shapes(i)
If oshp.Name = "Picture 4" Or oshp.Name = "Object 5" Then oshp.Delete
Next i
Next osld
End Sub
It's important to cycle through the shapes in reverse order because if you
go from 1 to the last shape and you eg delete Shapes(3) then Shapes(4)
becomes Shapes(3) and all the other shapes above will also change and confuse
the code!

Signature
Amazing PPT Hints, Tips and Tutorials
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
> Sub Makro1()
> ActiveWindow.Selection.SlideRange.Shapes("Picture 4").Select
[quoted text clipped - 5 lines]
> this will remove picture 4 and object 5 in "a slide" but i want to do it in
> all slides how can i do it?
bakalimbakalim - 24 Dec 2007 14:32 GMT
i tried but it deletes objects just a single slide
these objects are on every slide
"Line 9", "Picture 11", "Line 10", "Object 14"
and i want to delete them at once ? can i do it?
-----------------------------------------------------------------------------
That looks like code from the recorder? Not usually a good idea.
If it's at all possible never select shapes in vba and there's no need in
this case.
Is it "Picture 4" and "Object 5" on every slide?
Is so try this:
Sub zapem()
Dim osld As Slide
Dim oshp As Shape
Dim i As Integer
'cycle through all slides
For Each osld In ActivePresentation.Slides
'cycle through each shape in reverse order
For i = osld.Shapes.Count To 1 Step -1
Set oshp = osld.Shapes(i)
If oshp.Name = "Picture 4" Or oshp.Name = "Object 5" Then oshp.Delete
Next i
Next osld
End Sub
It's important to cycle through the shapes in reverse order because if you
go from 1 to the last shape and you eg delete Shapes(3) then Shapes(4)
becomes Shapes(3) and all the other shapes above will also change and
confuse
the code!

Signature
Amazing PPT Hints, Tips and Tutorials
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
> Sub Makro1()
> ActiveWindow.Selection.SlideRange.Shapes("Picture 4").Select
[quoted text clipped - 6 lines]
> in
> all slides how can i do it?