VBA & Macro Problems

PowerPoint VBA: Show or Hide Action Buttons Across Slides

Huda QurayshiHuda Qurayshi Nov 22, 2026 868 views

Question details

The user wants to show or hide action buttons across a PowerPoint presentation using VBA.

Show or Hide PowerPoint Action Buttons Across Slides with 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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

In PowerPoint, select Developer > Visual Basic. In the VBA editor, select Insert > Module.

2
Add the macros

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

3
Tag each button

In Normal view, select one action button. Open Developer > Macros, select TagSelectedActionButton, and choose Run. Repeat for each button you want to control.

4
Show or hide the buttons

Open Developer > Macros and run HideActionButtons to hide the tagged shapes. Run ShowActionButtons to make them visible again.

Tag Action Buttons and Change Their Visibility with VBA
Hidden buttons: Hidden buttons cannot be selected on the slide. Run ShowActionButtons before selecting or editing them.
Free Microsoft Office alternative

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.

Open and edit PowerPoint PPTX presentationsWork with slide shapes and action buttons in a familiar presentation interfaceUse a free, lightweight office suite for everyday editingMove between common Office document formats with less disruption
microsoft office alternative - wps office

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).