Created
August 31, 2018 22:19
-
-
Save MrFlick/2802218a1901268f13ab5e0e2ae1d445 to your computer and use it in GitHub Desktop.
Create animation from one shape to another (before/after)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub animate_to() | |
Dim oslide As slide | |
Set oslide = ActiveWindow.View.slide | |
Dim oeff As effect | |
Dim oani As AnimationBehavior | |
Dim pHeight As Single | |
Dim pWidth As Single | |
With ActivePresentation.PageSetup | |
pHeight = .SlideHeight | |
pWidth = .SlideWidth | |
End With | |
Dim startAt As shape | |
Dim endAt As shape | |
With ActiveWindow.Selection.ShapeRange | |
Set startAt = .Item(1) | |
Set endAt = .Item(2) | |
End With | |
Set oeff = oslide.TimeLine.MainSequence.AddEffect(startAt, msoAnimEffectPathDown, msoAnimateLevelNone, msoAnimTriggerAfterPrevious) | |
Set oani = oeff.Behaviors(1) | |
With oani.MotionEffect | |
dx = Format((endAt.Left - startAt.Left) / pWidth, "#0.000") | |
dy = Format((endAt.Top - startAt.Top) / pHeight, "#0.000") | |
.Path = "M 0 0 L " & dx & " " & dy | |
End With | |
endAt.Delete | |
End Sub | |
Sub listanimations() | |
Dim oslide As slide | |
Dim oshape As shape | |
Dim oeff As effect | |
Set oslide = ActiveWindow.View.slide | |
For Each oeff In oslide.TimeLine.MainSequence | |
Debug.Print "Path for Effect " & oeff.Index & " Shape= " & oeff.shape.Name _ | |
& ": " & oeff.Behaviors(1).MotionEffect.Path | |
Debug.Print oeff.Behaviors.Count | |
Debug.Print oeff.Behaviors(1).Type | |
Debug.Print oeff.EffectType | |
Next oeff | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment