deleting objects in all slides

  • Thread starter Thread starter bakalimbakalim
  • Start date Start date
B

bakalimbakalim

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?
 
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!
--
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
Back
Top