Site icon

How to remove unused PowerPoint master slides with a macro

How to remove unused PowerPoint master slides with a macro

Tl;dr: You have a template or have made a lot of master slides you don’t use. You want to share the file and don’t want all the master slides to be shared. Here is a macro to remove them in seconds

This is a random tip, but something you probably will never know that you can do. I’ve started using it and thought to make a quick blog to teach you.

Ok, so you bought a template and it has 150 master slides. Maybe you have a bunch of proprietary master slides you don’t want to share beyond the ones you are sharing with someone. Maybe you are just anal. Who knows.

You have used 10 master slides and don’t want people to see the 140 you are not using when sharing a PowerPoint file.

Only which ones did you use, and which did you not? You don’t want to accidentally delete ones that you used.

You could do the manual thing and manually check one by one, or you could use magic to do it in seconds.

This is the magic version.

Here is how to do it step by step.

First, make a new VBA macro

To create a macro, do the following (It’s not as scary as you think):

1/ On the View tab, choose Macros.

2/ In the Macro name: dialog box at the very top left, type a name for the macro (Type anything like “asd”, it doesn’t matter!).

 

3/ In the Macro list on the right-hand side (5 down), click create (see above).

 

4/ In the Description box, delete the lines of code that come up (the Sub stuff) and then copy paste the macro code in (it’s in the next section).

5/ Code looks like this. Click Play to run the macro.

6/ It runs. Done!

The macro code

You copy and paste the following code into the macro (module):

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

Then you press run as above.

Boom. Done. That’s it.

All the master slides you are not using are gone.

Send the file!

Drop mic.

If you ever find a macro you like online, do the same process to run it. You now know how to run macros. It’s very similar in Excel too.

Exit mobile version