How to Batch Update PowerPoint Slide Hyperlinks with VBA
Question details
The user needs a method to change hyperlink destinations in bulk across multiple slides or presentations using VBA.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- A large presentation has numerous shapes or texts linking to a specific slide (e.g., slide 77). The target slide has changed, requiring all corresponding links to point to a new destination (e.g., slide 2).
- Observed behavior
- Manually updating hundreds of internal slide hyperlinks one by one is highly inefficient and prone to error, requiring an automated batch process via VBA.
Ensure you save a duplicate backup copy of your presentation before running any VBA macros, as macro executions typically cannot be undone using the standard Undo feature.
Create and Run a VBA Macro to Update Hyperlink Sub-addresses
Use a custom VBA script to iterate through all slides and shapes, automatically finding and replacing the target slide number for internal hyperlinks.
Internal slide hyperlinks in PowerPoint use the 'SubAddress' property, which usually follows the format 'SlideID,SlideIndex,SlideTitle'. By writing a macro that loops through every shape in the presentation, you can identify links pointing to the old SlideIndex and replace them with the new one.
Open your presentation and press 'Alt + F11' on your keyboard to launch the Microsoft Visual Basic for Applications editor.
In the VBA editor, click 'Insert' from the top menu bar, and then select 'Module' to open a blank coding window.
Write a script utilizing 'For Each sld In ActivePresentation.Slides' and 'For Each shp In sld.Shapes' to loop through every shape. Use an 'If shp.ActionSettings(ppMouseClick).Action = ppActionHyperlink' statement to check for existing links.
Within the loop, check if 'shp.ActionSettings(ppMouseClick).Hyperlink.SubAddress' contains your old slide number. If it does, use the Replace function to update the SubAddress to your new slide target (e.g., replacing '77,' with '2,').
Click anywhere inside your completed code block and press 'F5', or click the 'Run' button (the green play icon) in the toolbar to execute the batch update.

Automate Presentations with WPS Office
WPS Presentation provides seamless compatibility with Microsoft PowerPoint files (.pptx) and supports advanced VBA macros in its professional editions, allowing you to run powerful automation scripts effortlessly.
- 1. Open your presentation: Launch WPS Presentation and open the file containing the hyperlinks you wish to update.
- 2. Access the Developer Tab: Navigate to the 'Developer' tab on the top ribbon to access the Macro and VBA toolset.
- 3. Open the VBA Editor: Click 'Visual Basic' or 'Macro' to open the code editor, and paste your batch-update VBA script.
- 4. Execute the Code: Run the script to instantly update all your slide hyperlinks across the presentation.

Frequently Asked Questions
Can I undo a VBA macro after running it in my presentation?
No, actions performed by a VBA macro usually clear the undo history and cannot be reverted using Ctrl+Z. Always test the macro on a duplicate copy of your presentation before running it on the original file.
Why is my VBA macro not finding the hyperlinks on my slides?
This usually happens if the script only checks the shape's ActionSettings, but the hyperlink is actually applied to the text inside the shape. Ensure your code loops through both `Shape.ActionSettings` and `Shape.TextFrame.TextRange.ActionSettings`.
How do I change external URL hyperlinks instead of internal slide links?
To change external web links, you need to modify your VBA script to check and replace the `Address` property (e.g., `shp.ActionSettings(ppMouseClick).Hyperlink.Address`) instead of the `SubAddress` property.
Does WPS Office support VBA for running these macros?
Yes, VBA is supported in specific editions of WPS Office, such as WPS Office Professional. You can write, edit, and run VBA scripts to automate tasks just as you would in Microsoft Office.




