PowerPoint has evolved into an app which is the Swiss Army knife of content creation, not only for presentations but also printed collaterals, videos and even interactive presentations.

In this second part of our series on supercharging PowerPoint interactive presentations with VBA we look at how you can provide your users with visual feedback for active areas of your slide using a mouse hover technique.

In part 1 you learned how you can add links to objects on slides that, when clicked, take the user to a different slide. But how does the user know that the object you’ve created the link for is an active object on your slide? In other words, how do they know it is clickable?

Good design plays an important part here. If you look at the slide below, it’s fairly obvious that the items in the left hand menu might do something:

BrightCarbon PowerPoint clear active icons in interactive presentations

However, in the next example, it’s not immediately clear that the three icons, or their corresponding text boxes link to other parts of the presentation:

You can add built-in PowerPoint visual feedback for the user by selecting the linked object and clicking the Insert tab in PowerPoint. Then, in the Links group click the Action button. As you discovered in Part 1, this opens the window below where you can set up your desired link in the Mouse Click tab. For the visual feedback you click the second Mouse Over tab and check the Highlight when mouse over option:

BrightCarbon PowerPoint Insert Action Highlight

Now when you hover your mouse over the active area in slide show mode you can see which content elements are active:

unclear active icons in Slide Show mode interactive presentations

In the example above, the mouse is hovered over the icon of the ship. Can you tell it’s an active object with a hyperlink? That very faint green dotted line is what PowerPoint uses by default. It’s not very clear at all is it? You might even say it’s pretty ugly! Not what you want for your interactive presentations.

You can do much better with VBA

VBA: Highlighting active objects in interactive presentations

You can use our custom VBA macro to do something much smarter:



Public Sub GraphicHover(ByRef oGraphic As Shape)

  oGraphic.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent1

End Sub


You can probably work out that this macro changes the fill colour of the object (called a Shape in VBA) to Accent 1 from the theme. Once you’ve added this to your PowerPoint file (read this to find out how) then you can uncheck the PowerPoint highlighting feature and instead assign the Mouse Over event to Run macro, selecting the GraphicHover macro:

BrightCarbon PowerPoint mouse hover macro action

Now when you move the mouse over the icon during a slide show the fill colour changes:

But as you can see at the end of the video there’s a major problem. When you move away from the icon, it doesn’t return to its original state.

What you need here is a Mouse Out event in the Actions window.

Spoiler alert, it’s not there! But don’t worry, with some out-of-the-box thinking there’s a clever hack to overcome this. What you need to do is to create an invisible shape which resets the hover state of the icon as you hover over this invisible shape. Here are the steps to create your invisible shape:

  1. First make sure you’re using a shape for the icon that can be filled e.g. an SVG icon or a PowerPoint vector shape (a PNG/JPG picture won’t work)
  2. Add our ResetGraphicHover macro from the code snippet below to your PowerPoint VBA project (read this to find out how)
  3. Insert a rectangle, sized and positioned to cover the whole slide
  4. From the Insert tab, click the Action button and set the Mouse Over event on the rectangle to run our macro ResetGraphicHover
  5. Right-click the rectangle and then click Format Shape…
  6. In the Format Shape pane, set the Fill / Transparency slider to 100% (don’t set it to No fill) and set the Line to No Line
  7. Send it to the back by clicking the Home tab followed by Arrange and Send to Back

Tip: to prevent this rectangle from getting deleted, moved or interfering with the editing of your slide, you can create it on a slide master layout instead.

Here’s the code for the reset hover macro:



Public Sub ResetGraphicHover(ByRef oCover As Shape)

  Dim oSld As Slide

  Dim oShp As Shape

  Set oSld = oCover.Parent

  For Each oShp In oSld.Shapes

    With oShp.Fill.ForeColor

      If .ObjectThemeColor = msoThemeColorAccent1 Then .ObjectThemeColor = msoThemeColorDark1

    End With

  Next

End Sub


Now when you run the interactive presentation, the icon fill colour changes as you hover over it and resets when you hover away from it, triggered as you hover over the invisible cover shape:

That’s much clearer visual feedback. You can go further and set all sorts of other properties in the hover and reset macros such as outline colour, transparency, line weights and so on:

 

Now that you know how to use VBA when creating interactive presentations, check out my post on restoring default slide master layouts with VBA or discover our Click-and-Explore service to find out how we can help create beautifully-designed interactive presentations for you.

Leave a comment
Written by

Jamie Garroch

Senior technical consultant

View Jamie Garroch's profile

Related articles

  1. Image of Simon L Simon L says:

    Hi thanks for the great insight once again. In addition to a question that I posed in the introduction blog about using a Mousedown function, as opposed to a mouse click, I have used the above to better highlight menu navigation buttons which looks great, however, as it is used to navigate to and from other slides I find that the button highlight cover / fill color used whilst hovering over the buttons has a memory and as you do not move off the button the reset hover is not triggered, can you assist with how to reset this given I do not think it is the same as resetting the slide animation as explained on Supercharging PowerPoint interactive presentations with VBA (Part 1) which I also tried. Much appreciated

  2. Image of Jamie Garroch Jamie Garroch says:

    Hi Simon. That’s a good point! You could have two macros for a given shape, one set to run on Mouse Over to do the highlighting and the other on Mouse Click to reset the shape’s style and go to the desired slide/URL etc. Note that because you want to perform a custom action on click that you need to code the macro to do the hyperlinking rather than using the standard PowerPoint interface. Try setting this as the mouse click macro as a good place to start:

    Public Sub ShapeClick(ByRef oShp As Shape)
    ResetGraphicHover oShp
    ActivePresentation.SlideShowWindow.View.GotoSlide 2
    End Sub

  3. Image of Sunil Sunil says:

    Hi there, i have this presentation (PPT) in which i have several hyperlinks, both as mouse clicks and mouse overs. Now when i view the slide show or export it as a PPS (powerpoint show) i see the hover animations, however when i export to PDF i dont get any of the animations, but i do get the hyperlinks that are mouse clicks. Is there any code for the hover/mouse over effect to be seen on the PDF like an interactive document. Please help.

    • Image of Jamie Garroch Jamie Garroch says:

      Hi Sunil. Converting to PDF will lose your animations, transitions and any embedded code. Are you using PDF to lock down your presentation, reduce its file size or something else? If the first, you could distribute or as a password protected read only file to convert it to video (no code) or simply save as a ppsm file.

  4. Image of Justin Justin says:

    I was able to get the initial color change working great when I hover over my initial shape. I am trying to have it change back when I hover over the transparent shape I am using but I am not having any luck on having it change back? Any idea on why this may be happing?

    • Image of Jamie Garroch Jamie Garroch says:

      Hi Justin. Have you set the mouse over event for the transparent shape to fire the reset macro? Is the reset macro firing? You can add a breakpoint in the reset macro to check by clicking in the margin of the code module (a red dot will appear). If the macro is firing the VBE window will appear at your breakpoint.

      • Image of Justin Justin says:

        Hey Jamie, it looks like the reset macro is firing. I tried setting the transparency on my reset rectangle shape to 50% to see if anything was happening to it when the reset macro was firing. Instead of switching my original shape back to it’s original color, it only changed the reset rectangle I created to a dark grey color. Would you be open to connecting with me on this? I would be happy to hire you to help consult me through this piece of my project.

        • Image of Jamie Garroch Jamie Garroch says:

          Hi Justin. If you drop an email to us via our contact form mentioning my name I’ll be happy to connect with you.

Leave a Reply

Join the BrightCarbon mailing list for monthly invites and resources

Tell me more!

We’d been badly let down and got hold of BrightCarbon on a Friday afternoon – with a Monday deadline! They were reassuring, professional, easy to work with. They listened and delivered great visuals – now adopted across the board.

Matt Dean byrne∙dean