Getting strange error

R

ruth

I built a small macro to eliminate subtitle placeholders on title slides.
Works terrific on a single slide, but needs to also work on multiple slides.

Sub PlacehldrSubTlDel()
Dim Sld As Slide
For Each Sld In ActiveWindow.Selection.SlideRange
ActiveWindow.Selection.SlideRange.Shapes.Placeholders(2).Delete
Next Sld
End sub

When multiple slides are selected, it throws this error out: "PowerPoint has
found an error that it can't correct. You should save presentations, quit,
and then restart PowerPoint." It stops on the first occurance of the delete
command, which I find odd because it does it fine with a single slide. Also,
it works well manipulating Placeholders(2) in other ways even with multiple
slides - it just chokes when deleting them with multiple slides.

Can someone help me understand why it errors and how I might better work it?

I work with PowerPoint version XP and all the selected slides are title
slides with subtitle placeholders present.
 
S

Shyam Pillai

Ruth,
Try:
For Each Sld In ActiveWindow.Selection.SlideRange
Sld.Shapes.Placeholders(2).Delete
Next Sld
But that works on the assumption that all the selected slides are title
slides and they all have sub title placeholders.

A more complete solution which works across the entire presentation is given
below, which checks for the title slide, verifies if subtitle is present and
deletes it.

Sub DeleteSubTitles()
Dim oShp As Shape
Dim oSld As Slide
Dim I As Integer
For Each oSld In ActivePresentation.Slides
If oSld.Layout = ppLayoutTitle Then
For I = 1 To oSld.Shapes.Placeholders.Count
With oSld.Shapes.Placeholders(I)
If .PlaceholderFormat.Type = ppPlaceholderSubtitle Then
.Delete
Exit For
End If
End With
Next
End If
Next oSld
End Sub
 
R

ruth

So, Shyam, when are you teaching your next class???? Sign me up.
Try:
For Each Sld In ActiveWindow.Selection.SlideRange
Sld.Shapes.Placeholders(2).Delete
Next Sld

That's what it was. I had it that way originally but changed it on edit and
didn't see the coding error. I see it now and thank you for pointing it out.
It works now, and it's a very controlled situation, so it's perfect as
simple as that.

Thanks for the additional info, too. I use that placeholder loop technique
in another routine where it's uncertain what type of slide is the target.

Thanks, Shyam.
Ruth
 

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

Top