Animation Resets when Shape Properties are changed in Powerpoint VBA - vba

I have a shape named box1 in my first slide. It has no animations attached to it. However, there are other shapes on the slide that contain lots of trigger animation sequences. If I run the macro ActivePresentation.Slides(1).Shapes("box1").Top = 400 the trigger animation state doesn't change. If I had changed the colour of some other shape via the trigger animation, it stays the same. It is perfect, only the position of box1 changes.
Now, if any animation is attached to box1 and the same macro is played, the animate state of the entire slide resets.
I tried using GetClickCount but that always remained 0 as the animations were all part of trigger sequences. I would appreciate any and all help on this front.
Thank you very much.

Related

In PowerPoint, can I create a button that captures the slide number it's on

I'm trying to create a VBA module such that, when a button is clicked, it will trigger a shape to fade in. I want to make it such that there is one of these buttons on every slide of the presentation, but every button will only trigger the shape on the same slide that the button is on. Is that possible, or do I need to create separate modules for every button?
I was thinking maybe you could use "Dim" and do something like
Sub FadeInShape()
Dim x as [the slide number of the slide on which the button was clicked]
but I don't know what that object would be called or if that object even exists.
Use a Trigger on a shape to start the animation. No VBA required:

Is there any event that fire for PowerPoint animations at start and end?

We're developing a PowerPoint plugin, recently we got a requirement from our client to start certain functionality after animation on an object is completed but I'm not able to find any animation finished or started events.
As PeterT has mentioned, there are no events fired when shapes animate. But here's a possible workaround. It may or may not fit your needs:
Add a shape the size of the animated shape, give it a Run Macro Action Setting on mouse-over (not on click). Have it run whatever macro you've written to do what's needed.
Make the shape 99% transparent and animate it to appear automatically after the main shape you've animated.
Result: your original shape animates on, then the (for all intents) invisible add'l shape appears and as soon as the user wiggles the mouse, the macro fires.
If you can't be sure that the user will have the mouse over the shapes in question, try adding a full-slide shape instead to trigger the macro. In that case, to avoid having the macro trigger repeatedly, you might need to have the macro make the shape that triggers it invisible or have the macro remove the action setting or the like.

How to make macros work while in Slide Show mode?

I have a set of grouped images in the PowerPoint slide.
When in Slide Show Mode (full screen) and I hover over these grouped images the slide event needs to take place. Usually when the mouse's slider is slide it ends full screen mode or moves to next slide. Instead I want the mouse slide event to take place. How can I do this in VBA or is there setting in PowerPoint to prevent this?
I'm not sure I understand what you're after, but perhaps this will help:
You can assign any shape (including shapes that are groups of other shapes) an Action Setting (it's on the Insert tab). The Action Setting can be triggered by either a mouse click or ... and this is what you want, I think ... a mouse OVER.
The action can do a variety of things, including trigger a macro (ie, a VBA subroutine in the same presentation file). The macro can receive a reference to the shape that triggered it as well. For example, if you assign this as the macro to run, when you hover over the shape, you'll get a message box with the shape's name:
Sub WhoAmI(oSh as Shape)
MsgBox oSh.Name
End Sub
MouseOver is actually not triggered by the mouse cursor being over the shape so much as by moving from NOT over the shape to being over the shape. Most of the time this distinction isn't important, but if you do a mouseover over a full-slide shape, it won't work.

How to auto advance a PowerPoint slide after an exit animation is over?

PowerPoint entrance animation set up with "Start: With Previous" starts right when a new slide is advanced. However, if you set up an exit animation in the same way, it doesn't start with a slide ending sequence. Instead, the "Start: On Click" trigger needs to be used and after your exit animation is over you still need one extra click just to advance to the next slide.
Workarounds to this are obvious: create a duplicate slide, make your ending animations from the original slide being your starting animations on the duplicate slide and let them be followed with whatever you want or create a transition slide with those ending animations only and set up "Change Advance slide -> Automatically after -> [the time it takes your animations to finish]".
These workarounds will make it work for your audience, visually. However, it has an impact on slide numbers you might need to adjust accordingly and/or duplicate content changes. If you are the only one creating and using your presentation, this might be just fine. But if you are creating a presentation in collaborative mode with three other people and don't even know who will be the presenter at the end, you can mess things up.
Let's be specific: most of my slides have 0.2s fly in entrance animation applied to blocks of content coming from right, bottom or left. Advancing to the next slide I want them to fly out in another 0.2s exit animation being followed by new slide 0.2s fly in entrance animation of the new blocks. The swapping of the blocks should be triggered while advancing to the next slide, as usually.
As mentioned, I'm not able to achieve this without one extra click between the slides.
I wrote a VBA script that should start together with an exit animation and will auto advance a slide after 0.3s when the exit animation is over. That way I should get rid of those extra clicks which are needed right now.
Sub nextslide()
iTime = 0.3
Start = Timer
While Timer < Start + iTime
DoEvents
Wend
With SlideShowWindows(1).View
.GotoSlide (ActivePresentation.SlideShowWindow.View.Slide.SlideIndex + 1)
End With
End Sub
It works well when binded on a box, button or another object. But I can't make it run on a single click (anywhere on the slide) so that it could start together with the exit animation onclick trigger. Creating a big transparent rectangular shape over the whole slide and binding the macro on it doesn't help either. By clicking it you only get the macro running, exit animation is not triggered.
Anyway, I don't want to bind the macro to any other workaround object but the slide itself.
Anyone knows how to trigger a PowerPoint VBA script on slide onclick event?
Anyone knows a secret setting that will make the exit animation work as expected i.e. animating right before exiting a slide while transitioning to the next one?
Anyone knows how to beat this dragon?
Thank you!
You could also set the TRANSITIONS (tab) -> Advance Slide After 00:00:00 seconds. You will need to set the SLIDESHOW (tab) to Use (Rehearsal) Timings. This will automatically advance the slide after the last animation action. You could, of course give it some seconds to wait, but it sounds like you just want to advance the slide.
You can intercept events in powerpoint using class module
In Class Module
In left combo (object) in VBA Explorer you can see ppt and in right your events
Private WithEvents ppt As PowerPoint.Application
In common module use
set x= new class1
Now you can use all events of presentation.
[]'s
OnSlideShowPageChange: VBA working while going to a slide without pressing any button
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = SSW.Presentation.Slides(x).SlideIndex Then
'PUT CODE HERE
End If
End Sub
Theire is a code havy workaround
You do that using the duplicate methode. However you duplicate using vba not manualy.
You can use the OnSlideShowPageChange
Test if the slide is one that need to be duplicated using a naming scheme of your choice. Then duplicate the slide. Then set the trasition effect to non and make it transition after 0 sec duration. Then remove all animations and add the exit animations desired.
Then you use the SlideShowEnd event to delete all the duplicate slides.
Note that you can use the SlideShowBegin to duplicate all the slides at once however duplicating a slide is not a fast tasck. So if you have a lot of havy slides to duplicate strating you presentation may take few seconds.
Sorry for not providing the code since it needs several lines.
For naming the slides you use also a macro.

Copying shapes between PowerPoint 2007 presentations along with their animations

I programmatically copy the shapes of an entire slide to a new slide in another presentation by performing origShape.Copy and then newSlide.Shapes.Paste().
(copy/paste the entire slide is unfortunately not an option for me here)
My problem is that Animation effects get really warped. Some are lost, others appear in the wrong order.
I thought that maybe after copying all the shapes I'll go over origSlide.TimeLine and will copy each animation effect to newSlide.TimeLine with the corresponding Shapes.
Is there a way of copying Animation effects between shapes without manually setting each and every parameter? (there are LOTS of these).
When copying shape-by-shape to a new slide, naturally the order of the animations gets ruined.
If we had for example the following animation sequence:
Rectangle flying in
Triangle flying in
Rectangle flying out
And we copy first the Rectangle and then the Triangle to a new slide, we'll get first both animations of the rectangle and then of the triangle.
My mistake was trying to solve this disorder by using Shape.AnimationSettings.
BEWARE OF SHAPE.ANIMATIONSETTINGS!!
This Property is kept only for backward compatibility with old versions of PowerPoint. If you modify any of its fields, all animations of a shape except the first one get AUTOMATICALLY ERASED !
So, the solution is this:
Copy shape by shape to new slide (no animations are lost, just mis-ordered). Then use Slide.TimeLine to go over the animation Effects and order them correctly using Effect.MoveTo, or Sequence.Clone and Effect.Delete.