Fix PowerPoint VBA Macros Assigned to Action Buttons in WPS Office
Question details
The user needs to run a PowerPoint VBA macro from an action button, but the macro fails in Slide Show mode because it relies on selection commands that are not available in that mode.

- Product
- WPS Office Presentation
- Device & OS
- not provided
- Scenario
- The user has a VBA macro that runs manually in edit mode and wants to assign it to an action button on a slide.
- Observed behavior
- The macro fails when triggered by the action button during Slide Show mode because Select and Selection are unavailable.
Open the presentation in WPS Office, press Alt+F11 to open the VBA editor, and check whether the macro contains Select, Selection, or SlideShowWindow commands before you modify the code.
Exit Slide Show Mode Before Running Selection-Based Macro Code
Use this solution when the macro must keep using selection commands to cut, paste, or reorder slides.
In Slide Show mode, PowerPoint and WPS Presentation do not provide the Select and Selection objects, so any macro that relies on them cannot complete the action. Exiting the show restores an editing view where those objects are available.
Press Alt+F11 in WPS Presentation and double-click the module that contains the macro assigned to the action button.
Insert ActivePresentation.SlideShowWindow.View.Exit at the beginning of the macro, before any code that uses Select or Selection.
Set the view to Slide Sorter or Normal view, and keep the slide manipulation code after the view change.
Send F5 or add SlideShowSettings.Run at the end of the macro to resume the presentation after the slide changes.

Use a Selection-Free Slide-Shuffling Macro Instead
Choose this alternative if you want the macro to run directly from an action button without exiting Slide Show mode.
Fix PowerPoint VBA Macros Assigned to Action Buttons in WPS Office
Open the VBA editor in WPS Presentation, add an exit command before selection-based slide operations, or rewrite the macro to move slides without Select and Selection, then reassign it to the action button and test in Slide Show mode.
- 1. Open the macro module: Open the presentation in WPS Presentation and press Alt+F11 to launch the VBA editor, then double-click the module that holds the action button macro.
- 2. Insert the Slide Show exit command: At the top of the macro, add ActivePresentation.SlideShowWindow.View.Exit if the macro uses Select or Selection.
- 3. Switch to an editing view: Set the view to Slide Sorter or Normal view before the code cuts, pastes, or moves slides.
- 4. Restart the presentation: Add SlideShowSettings.Run or send F5 at the end of the macro to resume the slide show.
- 5. Save and test: Save the macro-enabled presentation, start the show, and click the action button to confirm the macro works.

Frequently Asked Questions
Why does a PowerPoint VBA macro work manually but fail from an action button?
During Slide Show mode, Select and Selection are not available. The macro must either exit Slide Show with ActivePresentation.SlideShowWindow.View.Exit and switch to an editing view, or be rewritten to avoid selection commands.
How do I exit Slide Show mode from within a VBA macro in WPS Presentation?
Press Alt+F11 to open the VBA editor, open the macro module, and add ActivePresentation.SlideShowWindow.View.Exit at the start of the macro before any Select or Selection commands.
Can a slide-shuffling macro run directly from an action button during a presentation?
Yes. Write the macro using slide indexes and methods such as MoveTo or non-selection Cut and Paste, then assign it to the action button through Action Settings > Run macro and test it in Slide Show mode.
Will my PowerPoint macro-enabled file work in WPS Office after this fix?
WPS Office opens and saves PowerPoint .pptm and .ppt macro-enabled files. The VBA code can be edited in the built-in VBA editor, and the action button will work after the macro is adjusted.




