Mouse Over Animation In PowerPoint

John WilsonCEO PowerPoint Alchemy
CERTIFIED EXPERT
Published:

Introduction


In all recent versions of PowerPoint it is possible to trigger animations. This means the animation takes place when a certain shape is clicked. This allows you to run animation “on demand” and outwith the normal sequence of mouse clicks.

There is no obvious way to run an animation when a shape is just “moused over” rather than clicked. This is a common feature in web pages but not available in PowerPoint. A typical use might be to show a map or definition when an item is “moused over” and remove it again later.

 

Trigger Animations


Let’s start by creating a triggered animation.  
MO1.jpgLook at the screen shot. If the text has a fade animation and a fade exit in PowerPoint it will currently appear on the first click and fade away on the second. The desired behaviour is it will fade in on the first click ON THE TRIGGER SHAPE and out again on a second click of the shape.

To achieve this open the animation pane. Select both the fade in AND fade out entries (hold down CTRL) and set a trigger of the rectangle from the ribbon as shown. If you have an earlier version of PowerPoint you can use the drop arrow (circled) to choose TIMING and set the trigger here.
MO2.jpg 
mOTrigger.jpgWhen you run the slide show ("DEMO1.pptx") you should find that the text fades in when the button is pressed and out again on a second press.
 
So far, so good but how to make this happen on mouseover?
 

A Trick


A useful trick you may not know is essential to getting mouse over animation to work. Run the slide show again but this time press TAB and then ENTER. The animations take place, as if you had clicked the shape.
 

Press The Keys On Mouse Over


It is possible to trigger a macro on Mouseover. Select the train image and Insert Action.
 Open the Visual Basic Editor (ALT + f11).
Insert a module and paste in this simple code.
 
Sub anim(oshp As Shape)
                      Dim osld As Slide
                      Set osld = oshp.Parent
                      'Note alter the name here to match the trigger shape
                      If osld.Shapes("Rectangle 7").ZOrderPosition = 1 Then
                      SendKeys ("{TAB}")
                      SendKeys ("{ENTER}")
                      Else
                      osld.Shapes("Rectangle 7").ZOrder (msoSendToBack)
                      End If
                      End Sub
                      

Open in new window

Give the picture a mouseover action of Run Macro

MO3.jpg 
Most programmers hate using SENDKEYS but it is the only simple way to do this.
Finally if you don’t want to see the blue trigger shape in the show you can move it off slide where in will never be visible.
Text the sample DEMO1_code.pptm file.
 

IMPORTANT


Since the image now also has an action you need to be sure that TAB ENTER activates the trigger button and not the macro or you will get into a code loop. To do this make sure the button is sent to the back. TAB ENTER will always activate the first shape with an action. This is why the code checks that the trigger shape is at the back and moves it if necessary.
 

Downloads


This is the demo file without code.
DEMO1.pptx

You may download a fully working example here. Note it is in .ppt format as Experts Exchange does not yet support uploaded  .pptm files. Make sure you have macros and editing enabled when you try it.
DEMO1-withcode.ppt
3
19,392 Views
John WilsonCEO PowerPoint Alchemy
CERTIFIED EXPERT

Comments (5)

John WilsonCEO PowerPoint Alchemy
CERTIFIED EXPERT

Author

Commented:
Hi eric

I have changed the text to indicate the animations are in the PowerPoint file. I have attached the two demo files. I was unable to do this at first as EE rejects the upload of pptm files.

Commented:
Hi!
First of all, I'd like to thank you for sharing this! I've been Googling for ways to make mouse overs trigger an animation and just stumbled on this yesterday!
I've been looking for something like this because I didn't want to duplicate slides that mimic the effect of pop ups, etc.

I know that I shouldn't try to make fancy presentations but I just can't help trying to make interesting effects:
I have a list of text hyperlinks and I want it so that a cursor appears to the left of the text (or maybe a glowing version of the same text) only when I hover my mouse on to it. Also, a Callout appears with a short trivia about the text that's being highlighted.
But as soon as I move the mouse off it, the cursor and the callout automatically disappears.

I managed to make it work using your macro (I don't have any experience with "macros" prior to finding this guide) by having an image in the background serve as the trigger for the disappear animation.

But there's one problem though, as soon as those images disappear when I hover off the text hyperlinks (hover over the disappear trigger in the background), I always have to hover over the "Appear triggers" twice before the cursor and Callouts appear.

Is this

Commented:
Continued above:

But there's one problem though, as soon as those images disappear when I hover off the text hyperlinks (hover over the disappear trigger in the background), I always have to hover over the "Appear triggers" twice before the cursor and Callouts appear again.

It appears right away the first time I hover on the appear trigger but when I make it disappear, I always need to hover off and on twice before I can get it to show once more.

Is this some sort of a limitation of macros?
John WilsonCEO PowerPoint Alchemy
CERTIFIED EXPERT

Author

Commented:
The macro is really just pressing the trigger button. You would need to modify the ANIMATIONS to get what you need. Not that simple but certainly possible,

Simple demo here
Dear Mr. Wilson,

I have a request for you. I wanted to create a replica of Gratitude Logo Designed By Vic Bell @ codepen.io (Link for your reference: https://codepen.io/poziomq/pen/YGRdKG). The above script works fine but there is something that I need to accomplish the above said animation.

As you know that to create this animation, Body and Head will be 2 different objects and both of the objects can move simultaneously using Down Motion Path. So, I need to trigger the Head on Mouse Hover by applying another Motion Path. I named it "Face" and changed the object name in the script as well. The script works fine then but first it Sends the Face behind the Body object (maybe because of msoSendToBack) but if try to change the script to msoBringToFront, it doesn't work. May I know that what I can change in the script so that the Face object remain on top of all other objects?

Secondly, the Body which was following the Down Motion path during Slideshow and when I hover the mouse over the Face for the first time then Body reset it's position and start moving from the beginning along with the Face but then it works fine on the second mouse hover. The Face was also following the Down Motion path and if you hover your mouse over it then it also reset it previous motion path and start moving from the top. Is this could also be possible that the second Down Motion Path applied to Face should only trigger until the Mouse is over the face and stop repeating the second Down Motion path of the face, when you move your mouse away from that object.

Is there something that can be done to correct all those problems? Don't know anything about Visual Basic and sorry for asking too many questions. I hope you will not mind that.

Attaching the presentation for your reference.

Regards
Rajiv Kohli
Gratitude-Logo.pptm

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.