How to Use PowerPoint VBA to Add Text Based on Slide Titles
Question details
The user needs a VBA macro to automatically read slide titles in a large PowerPoint presentation, map specific keywords from the title to corresponding values, and insert the result into new text boxes.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Automating text box creation and data mapping across a presentation with over 150 slides based on slide title keywords separated by an underscore.
- Observed behavior
- Slide titles containing keyword pairs (e.g., Orange_and_Apple) need to be parsed and dynamically translated into specific mapped values (e.g., Italy_and_England) inside a formatted text box.
Ensure you have saved a backup copy of your presentation before running any VBA macros, and verify that the Developer tab is enabled in your PowerPoint ribbon.
Create a VBA Macro to Map Slide Titles to Text Boxes
Use a custom VBA script to loop through all slides, parse the slide titles using an underscore delimiter, and insert the mapped text into a designated text box.
This macro maps specific words (like Apple or Orange) to their corresponding geographical locations (like England or Italy). It splits the slide title by the underscore delimiter, applies the mapping, and combines the results.
You will need to adjust the coordinates (Left, Top, Width, Height) and font settings in the script to match the design requirements of your presentation.
Press Alt + F11 in PowerPoint to open the Visual Basic for Applications (VBA) editor window.
Click 'Insert' from the top menu bar and select 'Module' to create a new blank script window.
Write a VBA script that loops through 'ActivePresentation.Slides'. Retrieve the text using 'Slide.Shapes.Title.TextFrame.TextRange.Text', then use the 'Split' function with '_' as the delimiter to separate the words.
Use a Select Case statement or Dictionary to map the separated words to their new values. Finally, use 'Slide.Shapes.AddTextbox' to create a new text box with the combined mapped values.
Press F5 or navigate to Run > Run Sub/UserForm to execute the macro and update all 150+ slides automatically.

Run Macros Seamlessly in WPS Presentation
WPS Office provides excellent compatibility with Microsoft PowerPoint files, including robust support for VBA macros in its advanced editions. You can easily automate repetitive tasks like mapping text and updating slide layouts.
- 1. Download and Install WPS Office: Get WPS Office from the official website and install it on your computer.
- 2. Open Your Presentation: Launch WPS Presentation and open your file containing the slides you wish to automate.
- 3. Enable Developer Tools: Go to the Developer tab to access the built-in Macro and Visual Basic editor.
- 4. Execute Your VBA Script: Paste your slide-title mapping macro into the editor and run it to instantly update all slides.

Frequently Asked Questions
How do I extract just the title text from a PowerPoint slide using VBA?
You can access the title text using 'Slide.Shapes.Title.TextFrame.TextRange.Text'. Be sure to check if the slide actually has a title shape first by verifying 'Slide.Shapes.HasTitle' is true to avoid runtime errors.
How can I map multiple keywords in VBA without writing long If-Else statements?
The most efficient way to map multiple keywords (e.g., Apple to England) is to use a Scripting.Dictionary object or a Select Case statement. A Dictionary allows you to store key-value pairs and quickly retrieve the mapped value using the parsed title word as the key.
Can I format the text box created by the VBA macro?
Yes. When you use the 'AddTextbox' method, it returns a Shape object. You can then modify its properties, such as 'TextFrame.TextRange.Font.Size', 'Font.Color', and 'Font.Bold', to seamlessly match your presentation's style.




