Others

Add a PowerPoint Slide at the End Using Excel VBA

Jason MillerJason Miller Nov 20, 2026 868 views

Question details

Add a new slide to the end of an active PowerPoint presentation using Excel VBA.

Add a PowerPoint Slide at the End Using Excel VBA
Product
Microsoft Excel and Microsoft PowerPoint
Device & OS
not provided
Scenario
An Excel VBA macro controls an open PowerPoint presentation and needs to append a slide.
Observed behavior
The new slide is inserted at the beginning instead of after the existing slides.
Before you start

Open PowerPoint and make the presentation you want to modify active. The example requires at least one existing slide so it can reuse that slide's custom layout; enable macros in Excel if your security settings permit them.

Solution 1Recommended

Append a slide with PowerPoint's Slides.AddSlide method

Use the current slide count plus one as the insertion position to add the slide after all existing slides.

This example uses late binding to connect to a running PowerPoint instance and copies the layout from the presentation's first slide.

1
Open the VBA editor

In Excel, select Developer > Visual Basic, then choose Insert > Module.

2
Add the macro

Paste this code into the module: Public Sub AddSlideAtEnd() Dim ppApp As Object Dim ppPres As Object Dim pptSlide As Object Dim pptLayout As Object Set ppApp = GetObject(, "PowerPoint.Application") Set ppPres = ppApp.ActivePresentation Set pptLayout = ppPres.Slides(1).CustomLayout Set pptSlide = ppPres.Slides.AddSlide(ppPres.Slides.Count + 1, pptLayout) End Sub

3
Run the macro

Make the target presentation active in PowerPoint. In Excel's VBA editor, place the cursor inside AddSlideAtEnd and select Run > Run Sub/UserForm.

4
Check the presentation

Return to PowerPoint and check the last slide in the thumbnail pane. Save the presentation if the result is correct.

Append a slide with PowerPoint's Slides.AddSlide method
Presentation requirements: GetObject connects to a running PowerPoint instance, and ActivePresentation must be available. The first slide must exist because the macro uses its custom layout.
Free Microsoft Office alternative

Create and edit presentations with WPS Office

For everyday slide editing, WPS Office is a free, lightweight alternative with a familiar interface and support for Microsoft Office formats, making it easy to move existing files. It does not fix Excel-to-PowerPoint VBA automation.

Add and arrange presentation slides through a familiar editing interface.Open and edit Microsoft PowerPoint PPTX files and Excel XLSX files.Work with a free, lightweight Office alternative.Move existing documents into a familiar workspace.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Slides.Count + 1 add the slide at the end?

Slides.AddSlide inserts a slide at the specified position. Using Slides.Count + 1 places it immediately after the current last slide.

What layout does the new slide use?

The example uses ppPres.Slides(1).CustomLayout, so the new slide uses the same custom layout as the first slide. Choose another existing slide's CustomLayout if you need a different layout.

What if the presentation has no slides?

The example cannot access Slides(1) in an empty presentation. Add a slide in PowerPoint first or change the code to supply a valid custom layout from the presentation's slide master.

Why does GetObject fail to connect to PowerPoint?

GetObject requires a running PowerPoint instance. Open PowerPoint, open the target presentation, and make it active before running the macro again.