Others

How to Create Interactive Map Rollovers in PowerPoint Using VBA

Muhammad TalhaMuhammad Talha Oct 29, 2026 870 views

Question details

The user wants to create interactive map rollovers in a presentation using VBA macros to dynamically change shape colors when hovered over during a slide show.

How to Create Interactive Map Rollovers Using VBA
Product
PowerPoint
Device & OS
not provided
Scenario
Designing an interactive map for a presentation where regions highlight visually upon mouse hover.
Observed behavior
The software supports MouseOver actions to trigger macros but lacks a native MouseOut action, requiring a coding workaround to reset previously highlighted shapes.
Before you start

Ensure that the Developer tab is enabled in your presentation software to access VBA tools, and save your file as a Macro-Enabled Presentation (.pptm) to prevent losing your code.

Solution 1Recommended

Use a VBA Macro to Simulate MouseOver and MouseOut

Since PowerPoint lacks a native MouseOut action, you can use a VBA macro to track the active shape, change its color, and reset the previously hovered shape.

To create an interactive map rollover, you need to assign an action to each map shape. The macro triggered by the MouseOver action will highlight the current shape and revert the color of the last highlighted shape.

1
Rename the map shapes

Open the Selection Pane (Home > Select > Selection Pane) and rename all interactive map shapes with a common prefix, such as 'map_Region1', 'map_Region2', to easily identify them in your code.

2
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) editor. Go to Insert > Module to create a new module for your script.

3
Write the macro code

Write a VBA script that accepts a Shape object as a parameter. The script must store the name of the previously hovered shape in a global variable, reset its fill color, and then apply a highlight color to the currently hovered shape.

4
Assign the MouseOver action

Close the VBA editor. Select a map shape on your slide, go to Insert > Action, select the 'Mouse Over' tab, choose 'Run macro', and select your new macro. Repeat this for all relevant map shapes.

5
Test and save the presentation

Press F5 to enter Slide Show view and test the rollover effect. Go to File > Save As and select 'PowerPoint Macro-Enabled Presentation (*.pptm)' to save your interactive features.

Use a VBA Macro to Simulate MouseOver and MouseOut
Macro Security: Ensure that macros are enabled in your presentation software's Trust Center; otherwise, the MouseOver actions will not execute during the slide show.
Free Microsoft Office alternative

Try WPS Presentation for Interactive Slides

If dealing with VBA macros and coding workarounds is too complex, WPS Presentation provides an intuitive, lightweight, and highly compatible alternative. You can easily design interactive presentations and apply hyperlink-based rollovers without writing a single line of code.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installer for your operating system.
  2. 2. Install and Launch: Run the installer and follow the on-screen instructions to set up WPS Office on your computer.
  3. 3. Open Your Presentation: Launch WPS Presentation and seamlessly open your existing PowerPoint files to continue editing and adding interactive elements.
Free and lightweight office suiteFully compatible with Microsoft PowerPoint formats (.pptx, .ppsx, .potx)Intuitive interface with no steep learning curveSeamlessly add interactive hyperlinks and hover effects without coding
QA img-9

Frequently Asked Questions

Why doesn't the map shape revert to its original color when moving the mouse away?

PowerPoint does not have a native 'MouseOut' or 'MouseLeave' trigger for shapes. To fix this, your VBA macro must track the previously hovered shape in a global variable and manually reset its color when the mouse moves to a different shape or a background trigger shape.

Can I achieve a map rollover effect without using VBA macros?

Yes. A popular no-code workaround is to duplicate your main slide for each map region. On the main slide, assign a 'Mouse Over' action (Insert > Action) to each shape that hyperlinks to the corresponding duplicate slide, where that specific region is manually recolored.

Why are my VBA MouseOver macros not working in Slide Show view?

Macros only run if they are enabled in your security settings and if the file is saved in a macro-enabled format (.pptm or .ppsm). Also, ensure you are testing the presentation in Slide Show view, as MouseOver actions do not trigger in the normal editing view.