PowerPoint VBA: Show or Hide Action Buttons Across Slides
Question details
The user wants to show or hide action buttons across a PowerPoint presentation using VBA.

- Product
- Microsoft PowerPoint
- Device & OS
- not provided
- Scenario
- A presentation contains action buttons on multiple slides that need to be controlled as a group.
- Observed behavior
- The desired result is to change the visibility of matching buttons across slides without depending on shape IDs that can change when objects are copied or pasted.
Open the presentation in a desktop version of PowerPoint that supports VBA, and make sure the Developer tab is available. Save the presentation as a PowerPoint Macro-Enabled Presentation (.pptm) and enable macros only if you trust the file.
Tag Action Buttons and Change Their Visibility with VBA
Use a shared shape tag to identify action buttons and show or hide them throughout the active presentation.
Tags can identify shapes even when they are copied or pasted. The code below checks shapes directly on each slide; it does not search inside groups or shapes on slide masters.
In PowerPoint, select Developer > Visual Basic. In the VBA editor, select Insert > Module.
Paste this code into the module: Sub TagSelectedActionButton() ActiveWindow.Selection.ShapeRange(1).Tags.Add "ACTION_BUTTON", "YES" End Sub Sub HideActionButtons() SetActionButtonsVisible False End Sub Sub ShowActionButtons() SetActionButtonsVisible True End Sub Private Sub SetActionButtonsVisible(ByVal showButtons As Boolean) Dim sld As Slide Dim shp As Shape For Each sld In ActivePresentation.Slides For Each shp In sld.Shapes If UCase$(shp.Tags("ACTION_BUTTON")) = "YES" Then If showButtons Then shp.Visible = msoTrue Else shp.Visible = msoFalse End If End If Next shp Next sld End Sub
In Normal view, select one action button. Open Developer > Macros, select TagSelectedActionButton, and choose Run. Repeat for each button you want to control.
Open Developer > Macros and run HideActionButtons to hide the tagged shapes. Run ShowActionButtons to make them visible again.

Edit PowerPoint Presentations with WPS Presentation
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing presentations. It supports common PowerPoint formats for easier migration, but it does not fix PowerPoint-specific VBA issues; check macro compatibility before relying on existing code.

Frequently Asked Questions
Why use tags instead of shape IDs?
Shape IDs can change when objects are copied or pasted. Tags can travel with a shape, making a shared tag useful for identifying buttons across slides.
Can I use shape names instead of tags?
Yes. In VBA, reference a named shape with ActivePresentation.Slides(1).Shapes("ShapeName"), or loop through shapes and compare their Name property. Make sure your naming convention identifies the intended buttons.
How do I show the buttons after hiding them?
Open Developer > Macros, select ShowActionButtons, and choose Run. The macro sets the Visible property of each tagged shape to msoTrue.
Will the macro find buttons inside groups or on slide masters?
No. The sample checks shapes directly on each slide. Buttons inside groups or on slide masters require additional code to search those locations.
Why is my macro missing after saving?
VBA code is not retained in a standard .pptx file. Use File > Save As and choose PowerPoint Macro-Enabled Presentation (.pptm).




