27

My company recently created a new PowerPoint template. On its own without any slides, it is 9MB in size. This is completely unusable for sending to mobile devices and annoys customers. The main culprit is high resolution images on the master slides. Most of the time I don't use the 8 slides with the high resolution images. I have tried compressing the images, but that only get's the template down to 5MB empty, still too big.

Is there anyway to save the presentation an automatically discard the unused giant master slides. Obviously I can go in and delete the master slides, but was wondering if there is anything that allows you to automatically do this.

Scott
  • 1,683

6 Answers6

25

You can do this by creating a macro:

Sub SlideMasterCleanup()

Dim i As Integer
Dim j As Integer
Dim oPres As Presentation
Set oPres = ActivePresentation
On Error Resume Next
With oPres
    For i = 1 To .Designs.Count
        For j = .Designs(i).SlideMaster.CustomLayouts.Count To 1 Step -1
            .Designs(i).SlideMaster.CustomLayouts(j).Delete
        Next
    Next i
End With

End Sub
Moogle
  • 349
19

View as "slide masters". When you mouse over each slide master, you can see if that slide master is used. You can individually delete each slide master. Looks especially for those with pictures and remove the ones not used.

If you highlight the first slide, then keep hitting Delete repeatedly, only the slide templates that are not in use will be deleted. This is an easy way to manually roll through the templates quickly without worrying about removing one that is in use.

Scott
  • 1,683
hazelmoon
  • 206
5

The upvoted answer above still works and did work for me. The problem was that, when I copie the code I did not know what to do with it.

After a little research, I found that this is how to use the code above:

  1. Open your PPT doc
  2. Go to View, Click Macros
  3. Choose where you want to be able to run this macro in the dropdown
  4. Give it a name and create it.

Then a window pops up where you can paste the code.

Save it, go back to View-->Macros and Select the macro from the dropdown.

Click "Run" and DONE!

LadyLuck
  • 51
  • 1
  • 3
4

Updated @Moogle's VBA with @SandraRossi's procedure, plus print some statistics in the Immediate window of the VBA Editor (ALT + F11 or Developer > Visual Basic).

Sub SlideMasterCleanup()

Dim i As Integer Dim j As Integer Dim iLayouts As Integer Dim oPres As Presentation Set oPres = ActivePresentation On Error Resume Next

iLayouts = 0 Debug.Print "Before: # of designs:", oPres.Designs.Count With oPres For i = 1 To .Designs.Count iLayouts = iLayouts + .Designs(i).SlideMaster.CustomLayouts.Count For j = .Designs(i).SlideMaster.CustomLayouts.Count To 1 Step -1 .Designs(i).SlideMaster.CustomLayouts(j).Delete Next Next i End With Debug.Print "Before: # of layouts", iLayouts

' Delete masters having no layouts With oPres For i = 1 To .Designs.Count If .Designs(i).SlideMaster.CustomLayouts.Count = 0 Then .Designs(i).Delete End If Next i End With

iLayouts = 0 Debug.Print "After: # of designs:", oPres.Designs.Count With oPres For i = 1 To .Designs.Count iLayouts = iLayouts + .Designs(i).SlideMaster.CustomLayouts.Count Next i End With Debug.Print "After: # of layouts", iLayouts

End Sub

GrandWazoo
  • 41
  • 1
1

Below is basically the same answer as hazelmoon, but with screenshots and additional comments, especially a warning concerning the Master deletion which does not check if its Layouts are still used in the presentation.

In the menu View, click the button "Slide Master":

Powerpoint Slide Masters and Layouts

When you mouse over each slide Layout, you can see if that slide Layout is used:

enter image description here

You can individually delete each slide Layout. Look especially for those with pictures and remove the ones not used.

If you highlight the first slide, then keep hitting Delete repeatedly, only the slide templates that are not in use will be deleted. This is an easy way to manually roll through the templates quickly without worrying about removing one that is in use. If you select the first Layout, then keep hitting Delete repeatedly, only the slide Layouts that are not in use will be deleted.

This is an easy way to manually roll through the Layouts quickly without worrying about removing one that is in use.

Be careful, in Powerpoint for Office 365 MSO (and maybe more versions), deleting a Master will delete also its Layouts even if some of them are used (while deleting directly a Layout is not allowed if it's used). Consequently, delete first the unused Layouts repeatedly as you can be sure to not delete the used ones, then delete those Masters which don't have any Layout left.

Powerpoint Slide Masters and Layouts

1

The scripts above work but they do not eliminate all the unused master layouts, because either do not try (the first version) or because of the re-indexing that happens when you delete a master layout if it is not the last one -> Master Layout 4 is deleted and now former Master Layout 5 is Master Layout 4, which will not be deleted no matter what because the index will be on 5.

The scripts take this effect into account for the children layouts but not the master ones. The result is that when you execute the VBA, there are still master layouts left with unused layouts. To solve it you just need to count backwards also with the designs. Using a simplified version of @GrandWazoo code (w/o counters):

Sub SlideMasterCleanup()
    Dim i As Integer
    Dim j As Integer
    Dim oPres As Presentation
    Set oPres = ActivePresentation
    On Error Resume Next
    With oPres
'Delete unused layouts
        For i = .Designs.Count To 1 Step -1
            For j = .Designs(i).SlideMaster.CustomLayouts.Count To 1 Step -1
                .Designs(i).SlideMaster.CustomLayouts(j).Delete
            Next
        Next i
' Delete masters having no layouts
    For i = .Designs.Count To 1 Step -1
        If .Designs(i).SlideMaster.CustomLayouts.Count = 0 Then
            .Designs(i).Delete
        End If
    Next i
    End With
End Sub
sfcfs
  • 11