Access/VBA Library

RemoveUnusedLayouts

Remove unused Master Slides to clean up your final presentation.

Syntax

RemoveUnusedLayouts( aPresentation )
Parameters
Name Type Description
aPresentation Presentation Required. The presentation to be cleaned.
Code
Sub RemoveUnusedLayouts(aPresentation As Presentation)

    Dim DesignIndex As Long
    Dim LayoutIndex As Long
       
    On Error Resume Next
    With aPresentation
        '
        ' Loop through all designs
        '
        For DesignIndex = .Designs.Count To 1 Step -1
            '
            ' Loop through all layouts within current design
            '
            For LayoutIndex = .Designs(DesignIndex).SlideMaster.CustomLayouts.Count To 1 Step -1
                .Designs(DesignIndex).SlideMaster.CustomLayouts(LayoutIndex).Delete
            Next LayoutIndex
            '
            ' If no Layouts left, remove design also
            '
            If .Designs(DesignIndex).SlideMaster.CustomLayouts.Count = 0 Then
                .Designs(DesignIndex).Delete
            End If
        Next DesignIndex
    End With
End Sub

PowerPointtag:PowerPoint