OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Roll Over Demonstration

It is often asked if a roll over effect can be done in PowerPoint such that when the user moves the mouse over a shape during the slide show, a message is displayed on another section of the slide dynamically. This is can be easily achieved with some ingenuity and some VBA. Let use take a look how by creating a demo which does this exactly.

  Download

Sub DisplayMessage(oShp As Shape)
' Ascertain the position of the mouse by checking the
' index value of shape over which the mouse rests.
With SlideShowWindows(1).View.Slide _
    .Shapes(8).TextFrame.TextRange
    Select Case oShp.ZOrderPosition
        ' The purple rectangle on which the buttons rest
        ' we use the event here to clear the existing message while
        ' the mouse moves to the next shape

    Case 1
        .Text = ""
    Case 2
        .Text = "Descriptive Message when mouse moves over Shape 2"
    Case 3
        .Text = "Descriptive Message when mouse moves over Shape 3"
    Case 4
        .Text = "Descriptive Message when mouse moves over Shape 4"
    Case 5
        .Text = "Descriptive Message when mouse moves over Shape 5"
    Case 6
        .Text = "Descriptive Message when mouse moves over Shape 6"
    Case 7
        .Text = "Descriptive Message when mouse moves over Shape 7"
    Case 8
        .Text = "Descriptive Message when mouse moves over Shape 8"
    End Select
    DoEvents
End With
End Sub

Ensure that all the shapes have their mouse over action setting set to run the macro DisplayMessage.

Run the show and trying moving the mouse cursor over various shapes.


Copyright 1999-2018 (c) Shyam Pillai. All rights reserved.