logo
search
Office Settings & Configuration

How to Use a VBA Macro to Delete the Current Slide in PowerPoint Slide Show Mode

Steve KSteve K Oct 15, 2026 869 views

Question details

The user needs a VBA macro that can successfully delete the currently displayed slide while presenting in Slide Show mode.

How to Use a VBA Macro to Delete the Current Slide in PowerPoint Slide Show Mode
Product
PowerPoint / WPS Presentation
Device & OS
not provided
Scenario
Attempting to delete the active slide dynamically during a presentation (Slide Show mode).
Observed behavior
Standard selection-based commands like ActiveWindow.Selection.SlideRange.Delete fail because they rely on the normal editing view and do not identify the active slide during a presentation.
Before you start

Since slide deletions made via macros during a Slide Show cannot be easily undone, always create a backup copy of your presentation before testing this VBA script.

Solution 1Recommended

Use the CurrentShowPosition Property in VBA

Identify the active slide using the SlideShowWindow object's current position, then pass that index to the delete command.

In presentation mode, the active window changes from an editing view to a slide show view. Because of this, standard editing selection commands do not work. To bypass this, you must query the ActivePresentation.SlideShowWindow object to find out exactly which slide is currently being displayed on the screen.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the VBA editor, click on 'Insert' in the top menu and select 'Module' to create a blank script window.

3
Paste the Deletion Code

Copy and paste the following VBA code into the module window: Sub DeleteCurrentSlide() Dim slideNumber As Long slideNumber = ActivePresentation.SlideShowWindow.View.CurrentShowPosition ActivePresentation.Slides(slideNumber).Delete End Sub

4
Assign the Macro to an Action Button

Return to your presentation slides. Go to 'Insert' > 'Shapes' and add an Action Button. Right-click the button, select 'Action Settings', choose 'Run Macro', and select 'DeleteCurrentSlide'.

Use the CurrentShowPosition Property in VBA
Automated Execution: By placing the Action Button on the slide master, you can easily click it to delete any unwanted slide seamlessly while in Slide Show mode.
Advanced Presentation Management

Create and Run VBA Macros Seamlessly in WPS Presentation

WPS Presentation provides comprehensive support for VBA macros, enabling you to automate repetitive tasks like dynamically deleting slides during a slideshow. It's a highly compatible, powerful tool for advanced presentation management.

  1. 1. Download and Install: Download WPS Office and open your presentation file in WPS Presentation.
  2. 2. Access the VBA Editor: Navigate to the 'Tools' or 'Developer' tab on the ribbon and click on 'Visual Basic' to launch the VBA editor.
  3. 3. Insert and Run Your Macro: Insert a new module, paste your DeleteCurrentSlide VBA code, and assign it to an interactive shape on your slides to use during your presentation.
Native support for executing VBA macros to automate complex presentation workflowsFull compatibility with Microsoft PowerPoint (.ppt, .pptx, .pptm) formatsLightweight architecture ensures smooth presentations even with heavy macros
microsoft office alternative - wps office

Frequently Asked Questions

Why does ActiveWindow.Selection.SlideRange.Delete fail in Slide Show mode?

In Slide Show mode, there is no active 'selection' in the traditional sense because you are in a viewing environment, not an editing window. The macro must specifically target the SlideShowWindow to locate the active slide.

Can I use the Ctrl+Z shortcut to undo a macro deletion?

No. When a VBA macro executes an action, it typically clears the software's undo stack. Actions performed during Slide Show mode cannot be reversed with standard Undo commands, which is why testing on a copy is crucial.

How do I trigger a macro without exiting the presentation?

The most effective way to trigger a macro during a slideshow is by inserting an 'Action Button' or a 'Shape' onto your slide. In the Action Settings for that shape, select 'Run Macro' and link it to your specific VBA script.