Add or Remove Slides in PowerPoint with VBA

Adding a Slide to a Presentation

Use the Add method of the Slides collection

Add(Index as Long, Style as PpSlideLayout)

The second parameter “Style” uses an Enum called PpSlideLayout. There are more than 30 styles to choose from.

This code adds a blank slide at the presentation’s end:

Dim Pre as Presentation
Dim Sld as Slide
Set Pre = ActivePresentation
Set Sld = Pre.Slides.Add(Pre.Slides.Count + 1, ppLayoutBlank)

Removing a Slide from a Presentation

Use the Delete method from the Slides collection

Delete(Index as Long)

The following code removes all the slides:

Dim Pre As Presentation
Set Pre = ActivePresentation
Dim x As Long
For x = Pre.Slides.Count To 1 Step -1
Next x

Note. Tested versions: 2007 and 2010

This entry was posted in PowerPoint and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s