Add and Delete Slides in Powerpoint Presentation Using VBA
This article explains how you can add and delete slides from a PowerPoint presentation object.
Add New Slide
The following code will add a new slide to the active presentation object:
Dim objPresentaion As Presentation Set objPresentaion = ActivePresentation Call objPresentaion.Slides.Add(1, PpSlideLayout.ppLayoutBlank)
The first parameter specifies what index the new slide will get. So An index “1” will make it the first slide, pushing the rest of the slides down:
The second parameter is the slide type which you can choose from the PpSlideLayout enumeration.
Note: When typing objPresentaion.Slides.Add, objPresentaion.Slides.AddSlide might show up in intellisense. Do not use that as it will not work:
Delete Slide:
Slides can be delete using the code below:
Dim objPresentaion As Presentation Set objPresentaion = ActivePresentation objPresentaion.Slides.Item(1).Delete
Where “1” is the index of the slide which starts at “1”