VBA & Macro Problems

How to Hide a Shape on a Future Slide Using PowerPoint VBA

Huda QurayshiHuda Qurayshi Nov 2, 2026 869 views

Question details

The user needs to know the correct VBA syntax to hide or show a picture or shape located on a future slide using its name.

How to Hide a Shape on a Future Slide Using PowerPoint VBA
Product
PowerPoint / WPS Presentation
Device & OS
not provided
Scenario
Creating an interactive presentation or game where an action on the current slide dynamically alters the visibility of elements on upcoming slides.
Observed behavior
The user knows the target slide number and the specific shape name, but is unsure of the exact macro syntax required to correctly reference and modify the shape across different slides.
Before you start

Ensure your presentation is saved as a Macro-Enabled file (.pptm) so your VBA code is preserved, and verify that the Developer tab is enabled in your software's ribbon.

Solution 1Recommended

Use FindBySlideID and Reference the Shape by Name

This method uses the unique Slide ID to target the correct slide and references the shape directly by its unique name to change its visibility.

Referencing a slide by its Slide ID rather than its index (slide number) is highly recommended. If you add, delete, or rearrange slides later, the Slide ID remains constant, preventing your macro from breaking.

When the shape has a unique name on the slide, you do not need its shape index or ID; you can simply call its name.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to launch the Visual Basic Editor.

2
Declare the Slide Variable

Within your macro module, declare a variable for the slide by typing: Dim osld As Slide

3
Target the Slide by ID

Set the variable to your target slide using its ID. For example: Set osld = ActivePresentation.Slides.FindBySlideID(284)

4
Change the Shape Visibility

Set the Visible property of the specific shape to False. Add the following line: osld.Shapes("Picture 2").Visible = False (Replace "Picture 2" with your shape's actual name).

Use FindBySlideID and Reference the Shape by Name
Locating the Slide ID: If you are unsure of your target slide's ID, you can run a temporary one-line macro while viewing the slide: MsgBox ActiveWindow.View.Slide.SlideID to retrieve it.
Advanced Presentation Features

Create Interactive Macros Seamlessly in WPS Presentation

WPS Office includes robust support for VBA and macros, allowing you to build complex, interactive presentations exactly as you would in Microsoft PowerPoint. Enjoy advanced developer tools, exceptional format compatibility, and a familiar interface.

  1. 1. Download WPS Office: Install WPS Office for free from the official website.
  2. 2. Open Your Presentation: Launch WPS Presentation and open your .pptm file. WPS will smoothly load all existing shapes and macros.
  3. 3. Access Macro Tools: Navigate to the Developer tab on the ribbon and click on 'Macros' or 'VBA Editor' to view and edit your code.
  4. 4. Run and Test: Start your Slide Show to test the interactive shapes and VBA logic in real-time.
Fully compatible with Microsoft PowerPoint macro formats (.pptm)Built-in robust VBA editor for creating and managing slide scriptsLightweight, intuitive interface that operates fast on any deviceFree to use for everyday office tasks and interactive presentations
QA img-9

Frequently Asked Questions

How do I find or change the name of a shape in my presentation?

You can find a shape's current name by opening the Selection Pane. Go to the Home tab, look for the 'Select' or 'Find & Select' dropdown, and choose 'Selection Pane'. This will list all elements on the slide. You can double-click any name in this pane to rename your shape to something easily recognizable for your macros.

Why is it better to use SlideID instead of SlideIndex in VBA?

The SlideIndex is simply the sequential order of the slides (1, 2, 3). If you insert a new slide at the beginning, the SlideIndex of all subsequent slides changes, which breaks macros relying on that number. The SlideID is a unique identifier generated when the slide is created and remains permanent regardless of how slides are reordered.

How can I reset all my hidden shapes to be invisible when the presentation starts?

You can create an initialization macro that runs when you click a 'Start' button on your title slide. In this macro, write a script that targets each specific slide ID and sets the visibility of the shapes to False (e.g., osld.Shapes("Picture 2").Visible = False) before navigating to the main content.