logo
search
VBA & Macro Problems

How to Display a VBA Total on a Different PowerPoint Slide

Bushra ParveenBushra Parveen Oct 23, 2026 868 views

Question details

The user needs a PowerPoint VBA macro to update and display a total score on a shape located on a non-active (different) slide.

How to Display a VBA Total on a Different PowerPoint Slide
Product
PowerPoint
Device & OS
not provided
Scenario
Running a VBA script during an active presentation to dynamically push updated scores or totals to specific shapes across multiple slides.
Observed behavior
The current VBA script successfully updates the score on the active slide but fails to write the new total to the designated shape on another slide.
Before you start

Ensure you know the exact slide index (or name) and the specific shape name on the target slide where you want the new total to appear.

Solution 1Recommended

Directly Reference the Target Slide and Shape in VBA

Instead of using the ActiveSlide object, explicitly specify the target slide and shape using the ActivePresentation object to push text updates anywhere in the presentation.

By referencing the exact slide index and shape name, PowerPoint VBA can manipulate text frames on any slide without requiring the slideshow to navigate to that slide first.

1
Open the VBA Editor

Press Alt + F11 in PowerPoint to open the Visual Basic for Applications (VBA) editor and locate the macro that calculates your total.

2
Identify Target Slide and Shape

Determine the slide number (represented by 'x') and the exact name of the shape (represented by 'sShapeName') that will receive the total.

3
Apply the Reference Code

Insert the following line into your macro: ActivePresentation.Slides(x).Shapes(sShapeName).TextFrame.TextRange.Text = NewTotal

4
Replace Placeholder Values

Replace 'x', 'sShapeName', and 'NewTotal' with your actual variables or hardcoded values (e.g., ActivePresentation.Slides(2).Shapes("ScoreBox").TextFrame.TextRange.Text = 150).

Directly Reference the Target Slide and Shape in VBA
Understanding Hardcoded Values: Hardcoded values are specific data written directly into the code (like the number 2 for slide 2), whereas variables store data that can change dynamically during execution.
Automate with WPS Office

Create and Run Macros Seamlessly with WPS Office

WPS Presentation provides robust support for VBA macros, allowing you to easily automate cross-slide updates, create interactive slideshows, and manage complex scores just like you would in Microsoft PowerPoint.

  1. 1. Download and Install WPS Office: Get the latest version of WPS Office and ensure the VBA module is enabled.
  2. 2. Open Your Presentation: Launch WPS Presentation and open your macro-enabled presentation file.
  3. 3. Access the Developer Tab: Navigate to the Developer tab on the ribbon and click on 'Visual Basic' to open the VBA Editor.
  4. 4. Run Your Macros: Insert your VBA code to reference different slides and run your macros seamlessly during the slideshow.
Highly compatible with Microsoft PowerPoint macro-enabled (.pptm) formatsBuilt-in robust VBA environment for custom scripting and automationLightweight, fast performance with a familiar user interface
microsoft office alternative - wps office

Frequently Asked Questions

How do I find the exact name of a shape in PowerPoint?

You can find a shape's name by opening the Selection Pane. Go to the Home tab, click on Select in the Editing group, and choose Selection Pane. You can also double-click the shape's name in this pane to rename it to something easily recognizable for your VBA code.

Why does my VBA code throw an error when updating the text?

This usually happens if the slide index or shape name does not exist, or if the targeted shape does not support text frames (like a line). Verify your spelling and ensure the target shape can hold text.

Can I use the slide name instead of the slide index number?

Yes. If you frequently reorder slides, it is safer to use the slide's name. You can modify the code to ActivePresentation.Slides("YourSlideName").Shapes(sShapeName)... to ensure the correct slide is always targeted regardless of its position.