How do I only delete certain slides in a presentation?

One thing you’re likely to discover when developing a robust approach for automatic updates is that you might have to come up with a way of scrapping the previous update and replacing it with the latest one.

At least that’s what I came to painfully realize a month after I fully coded my PowerPoint slides consolidation

The way I chose to go about it was by deleting slides on the basis of their SlideIDs, which unlike the Slide indexes that indicate the position of a slide in a presentation, will not change when new slides have been added or removed.

This would work great as I needed to remove everything but the section header slides, whose Slide IDs I hard-coded in the code below:

As time progressed, I discovered that I also needed to have a more custom approach in place to cater for those occasions when I had to update slides due to erroneously generated data.

One approach would be to ask for user input and delete the slides that contain a specified word in their header.

Yet another approach could be that only slides that have a certain layout or number of shapes get deleted

But how do I know how many shapes a slide has?

Easy! You can use the code below to have the shape count shown in a message box upon entering a slide’s presentation position.

Happy VBA coding!