VBA & Macro Problems

How to Replace Text Boxes or Shapes on Multiple PowerPoint Slides Using VBA

Jason MillerJason Miller Nov 2, 2026 869 views

Question details

The user needs an automated way to replace specific text boxes or shapes across multiple PowerPoint slides while retaining their original position, dimensions, font, and color properties.

How to Replace Text Boxes or Shapes on Multiple PowerPoint Slides Using VBA
Product
PowerPoint
Device & OS
not provided
Scenario
Editing a large presentation where a repeating object, shape, or text box needs to be swapped out consistently across dozens of slides.
Observed behavior
Manual replacement across many slides is time-consuming and risks misalignment. An automated approach using VBA is needed to ensure properties are perfectly preserved during the swap.
Before you start

Save a backup copy of your presentation before running any macro, as VBA script executions usually cannot be undone using the standard Undo shortcut.

Solution 1Recommended

Use a VBA Macro to Automate Shape Replacement

Write a VBA macro that loops through all slides, finds the target shape by text or position, creates a replacement with the same coordinates, and deletes the original.

VBA (Visual Basic for Applications) allows you to automate repetitive tasks in presentation software. By writing a short script, you can iterate through every slide, pinpoint a shape based on its name, text content, or coordinates, and swap it with a new shape. The script can dynamically copy the original dimensions, position, and formatting to the new object.

1
Open the VBA Editor

Open your presentation and press `Alt + F11` on your keyboard to launch the VBA Editor window.

2
Insert a New Module

In the top menu, click `Insert` and select `Module` to create a blank workspace for your macro.

3
Write the Loop Script

Define your sub-routine and write a `For Each` loop to iterate through `ActivePresentation.Slides`, and a nested loop to iterate through `Slide.Shapes`.

4
Identify the Target Shape

Inside the loop, use an `If` statement to identify the shape you want to replace. You can match it by its name (e.g., `If shp.Name = "OldShapeName" Then`) or by its text.

5
Capture Properties and Replace

Store the old shape's `.Top`, `.Left`, `.Height`, and `.Width` properties into variables. Use the `.AddShape` or `.Paste` method to introduce the new shape, apply the stored coordinate variables to it, and finally use `shp.Delete` to remove the original shape.

6
Run the Macro

Press `F5` while inside the VBA editor to execute the script and perform the batch replacement across all slides.

Use a VBA Macro to Automate Shape Replacement
Enable Macros: Ensure that your Trust Center settings allow macros to run; otherwise, the script execution will be blocked.
Efficient Presentation Editing

Automate Presentation Edits with WPS Office

WPS Presentation provides excellent support for VBA macros, enabling you to seamlessly execute customized scripts to replace shapes, text boxes, and formatting elements across hundreds of slides. It offers a familiar interface and comprehensive macro capabilities.

  1. 1. Download and Install: Download WPS Office Free and install it on your device.
  2. 2. Open Your Presentation: Launch WPS Presentation and open your .pptx or .pptm file.
  3. 3. Access Macro Tools: Navigate to the 'Tools' tab on the ribbon and click 'Macro', or simply press `Alt + F11` to open the VBA Editor.
  4. 4. Execute the Script: Paste your shape-replacement macro into a new module and hit 'Run' to apply changes instantly.
Full support for VBA macros to automate repetitive design tasksHighly compatible with Microsoft PowerPoint (.pptx, .ppt, .pptm) formatsLightweight architecture for fast processing of large presentationsFamiliar user interface that requires zero learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Can I replace shapes across all slides without using VBA?

If the shape is part of the slide layout, you can simply edit the Slide Master (View > Slide Master) to replace the shape, and it will automatically update across all slides using that specific layout. However, if the shapes were manually placed on standard individual slides, a VBA macro or a dedicated add-in is required.

How do I find the exact name of a shape for my VBA macro?

You can find a shape's system name by selecting it, going to the Home tab, clicking 'Select' (usually under Editing tools), and opening the 'Selection Pane'. The Selection Pane displays the names of all objects on the current slide, which you can use in your VBA `If` statements.

Why is my macro not copying the font color of the original text box?

When coding a shape replacement, VBA does not automatically transfer text formatting. You must explicitly tell the script to copy properties like `Font.Name`, `Font.Size`, and `Font.Color.RGB` from the old shape's `TextFrame` to the new shape's `TextFrame` before deleting the old object.