Yes, it is handy to be able to automatically delete slides from a PowerPoint presentation
There are instances, however, when it might be smarter to delete the content of a slide rather than the whole slide.
What you can use in such cases is the VBA snippet below, which will loop through all slides of your presentation and delete all content from each slide apart from its title.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Delete_All_but_Title() | |
Dim p As Presentation | |
Set p = ActivePresentation | |
Dim PPS As Slide | |
'*************************** | |
For Each PPS In p.Slides | |
Dim i As Shape | |
For Each i In PPS.Shapes | |
If i.Type <> msoPlaceholder Then i.Delete | |
Next i | |
Next PPS | |
End Sub |
In case you you only want to delete a certain element of the slide rather than all of its content, you can use the VBA snippet below to restrict what gets deleted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Delete_shape_type() | |
Dim p As Presentation | |
Set p = ActivePresentation | |
Dim PPS As Slide | |
Dim Sh As Shape | |
'*************************** | |
For Each PPS In p.Slides | |
For Each Sh In PPS.Shapes | |
If Sh.Type = msoPicture Then Sh.Delete | |
If Sh.Type = msoTextBox Then Sh.Delete | |
If Sh.Type = msoAutoShape Then Sh.Delete | |
Next Sh | |
Next PPS | |
End Sub |
Full list of the VBA syntax of all Office shapes can be found hereÂ
Happy VBA coding!