2
votes

Is it possible to identify the shape ID that triggers a mouseover on a powerpoint presentation.

What I want to do is have a series of shapes on a slide with titles, and when the user mouseovers a shape, I want to use VBA to show more details about the shape in another part of the page, possibly in a separate help text box. I could then use the selected shapes ALt Text to display in the help box. What i can't see is how to identify what shape has triggered the mouseover macro. Is this possible? If I can identify the shape that triggered the action, I could then get info about that shape.

2

2 Answers

2
votes

The Shape object in PowerPoint does not allow you to interact with its events as you normally would with other objects in VBA code. The only two 'events' that are exposed are not actually VBA events. They are a special class called Actions, and they are 'ppMouseOver' and 'ppMouseClick'. If you know all the information about your shapes and their corresponding information beforehand, you could write some code to do what you want, but it would all be hard-coded, which is probably not what you want.

You could run a routine something like this when the presentation starts:

Sub SetActionsRoutine()

    Shape1.ActionSettings(ppMouseOver).Action = ppActionRunMacro
    Shape1.ActionSettings(ppMouseOver).Run = "showInformation1"

    Shape2.ActionSettings(ppMouseOver).Action = ppActionRunMacro
    Shape2.ActionSettings(ppMouseOver).Run = "showInformation2"
    ...
    ...
End Sub

And then whenever you did a MouseOver of those shapes, one of the following routines would run.

Sub showInformation1()
    myTextBox.Text = Shape1.AlternativeText
End Sub

Sub showInformation2()
    myTextBox.Text = Shape2.AlternativeText
End Sub

This is very limited and requires that you write a subroutine for every shape on your slide. Probably not the approach you want, but again, with PowerPoint, your options are very limited.

0
votes

New to StackOverflow, late to answer, but you can do this:

Sub RespondToShape(oSh as Shape) MsgBox "You clicked " & oSh.Name End Sub

Assign every shape you want to interact with an Action setting of Run Macro and choose RepondToShape as the macro.