问题
Is it possible to change the shape color on mouse hover using VBA in PowerPoint?
I tried creating the same effect using animations+trigger but it requires a click. However I would like to change the shape color as I hover the mouse over it and change it back to the original color as I hover the mouse to next shape. Is this possible to achieve?
Thanks in advance.
回答1:
This is possible with a hack approach to overcome the fact that PowerPoint doesn't support the mouse-out event. What you can do is write a mouse-over macro as follows to change the colour:
Option Explicit
Public myShape as Shape ' Global reference to mouse over shape
Sub MouseOver(oShp As Shape)
Set myShape = oShp
With oShp
' Change the properties you need here
End With
End Sub
Assign that to your shape via Insert / Action / Mouse Over / Run Macro
Next, and this is the hack for no mouse-out event, add a rectangle shape to your slide on the bottom layer. Set the fill transparency to 100% and assign the following macro to it's mouse-over event:
Sub MouseOutHack()
With myShape
' Reset the properties you need here
End With
End Sub
Now, when you move the mouse over your shape, it's properties will change and when you move it out of the shape, the invisible background shape will trigger the resetting of the properties you choose.
来源:https://stackoverflow.com/questions/32964688/macro-to-change-shape-colour-on-mouse-hover-in-powerpoint