Add a PowerPoint Slide at the End Using Excel VBA
Question details
Add a new slide to the end of an active PowerPoint presentation 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.
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.
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.
In Excel, select Developer > Visual Basic, then choose Insert > Module.
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
Make the target presentation active in PowerPoint. In Excel's VBA editor, place the cursor inside AddSlideAtEnd and select Run > Run Sub/UserForm.
Return to PowerPoint and check the last slide in the thumbnail pane. Save the presentation if the result is correct.

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.

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.




