How to Display a VBA Total on a Different PowerPoint Slide
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.

- 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.
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.
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.
Press Alt + F11 in PowerPoint to open the Visual Basic for Applications (VBA) editor and locate the macro that calculates your total.
Determine the slide number (represented by 'x') and the exact name of the shape (represented by 'sShapeName') that will receive the total.
Insert the following line into your macro: ActivePresentation.Slides(x).Shapes(sShapeName).TextFrame.TextRange.Text = NewTotal
Replace 'x', 'sShapeName', and 'NewTotal' with your actual variables or hardcoded values (e.g., ActivePresentation.Slides(2).Shapes("ScoreBox").TextFrame.TextRange.Text = 150).

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. Download and Install WPS Office: Get the latest version of WPS Office and ensure the VBA module is enabled.
- 2. Open Your Presentation: Launch WPS Presentation and open your macro-enabled presentation file.
- 3. Access the Developer Tab: Navigate to the Developer tab on the ribbon and click on 'Visual Basic' to open the VBA Editor.
- 4. Run Your Macros: Insert your VBA code to reference different slides and run your macros seamlessly during the slideshow.

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.




