Finding all slides based on certain layout?

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Finding all slides based on certain layout?

Post by New Daddy »

You cannot delete a layout if there are slides that are based on that layout.

Is there a way to find all slides based on certain layout? (In Microsoft Word, you can find all paragraphs based on certain Style. I'm looking for something equivalent in Powerpoint.)

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Finding all slides based on certain layout?

Post by HansV »

I suspect that you will need VBA for that. Loop through the slides and look at their CustomLayout property.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Finding all slides based on certain layout?

Post by Rudi »

Hi,

If your question also has context to deleting all slide masters that are NOT linked to slides in the presentation; IOW, slide layouts not being used, I have code that I use on a regular basis that deletes these layout slides and clean up the template from excess layouts in the Slide Master view. If you want this code I'll be happy to upload it.

Regarding your question...here is a non VBA way to identify all slides in the presentation that are connected to a specific master layout...don't laugh...but it should work well...
Go to the slide layout you want to get rid of, draw a big red X on that layout, then go back to normal view and you can easily see which slides have that particular layout as they will all show a big red X. :grin:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Finding all slides based on certain layout?

Post by HansV »

Hey, that's clever! :thumbup:
Best wishes,
Hans

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: Finding all slides based on certain layout?

Post by New Daddy »

Rudi wrote:Hi,
Regarding your question...here is a non VBA way to identify all slides in the presentation that are connected to a specific master layout...don't laugh...but it should work well...
Go to the slide layout you want to get rid of, draw a big red X on that layout, then go back to normal view and you can easily see which slides have that particular layout as they will all show a big red X. :grin:
I love it! and I don't think I've laughed as much in recent years. Thanks for that! :rofl:

On a more serious note, can you let me have the code to clean up layouts?

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Finding all slides based on certain layout?

Post by Rudi »

As requested...
Credit to John Wilson for the code he designed for me in the Microsoft Community
BTW: If you need VBA code for PowerPoint, this is a great source!

Code: Select all

Sub zapSpareMasters()
Dim iDes As Integer
Dim iLay As Integer
    On Error Resume Next
    For iDes = ActivePresentation.Designs.Count To 1 Step -1
        'This will only delete layouts not in use
        For iLay = ActivePresentation.Designs(iDes).SlideMaster.CustomLayouts.Count To 1 Step -1
            ActivePresentation.Designs(iDes).SlideMaster.CustomLayouts(iLay).Delete
        Next iLay
        'if Empty Delete Master
        ActivePresentation.Designs(iDes).Delete
    Next iDes
End Sub
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.