How to Use a VBA Macro to Delete the Current Slide in PowerPoint Slide Show Mode
Question details
The user needs a VBA macro that can successfully delete the currently displayed slide while presenting in 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.
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.
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.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the VBA editor, click on 'Insert' in the top menu and select 'Module' to create a blank script window.
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
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'.

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. Download and Install: Download WPS Office and open your presentation file in WPS Presentation.
- 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. 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.

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.




