Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / December 2007

Tip: Looking for answers? Try searching our database.

deleting objects in all slides

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bakalimbakalim - 19 Dec 2007 09:59 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.