PDA

View Full Version : Animate star through shapes outline/border in powerpoint vba



papuapu
09-06-2021, 10:21 AM
Sir,
I need some help.
I want to animate a star through any powerpoint shapes(here decagon) outline/border using vba code.
I make an animation for referance & giving custom path through outline/border of the decagon shape manually.


Dim effNew As Effect
Dim aniMotion As AnimationBehavior

' Add custom effect to the shape


Set effNew = ActivePresentation.Slides(1).TimeLine.MainSequence _
.AddEffect(Shape:=Star5Points1, effectId:=msoAnimEffectCustom, _
Trigger:=msoAnimTriggerWithPrevious)

' Add Motion effect
Set aniMotion = effNew.Behaviors.Add(msoAnimTypeMotion)

' Set Motion Path as custom path ie outline of shape
aniMotion.MotionEffect.Path = string


I cannot configure this "aniMotion.MotionEffect.Path = string"
section ie string = ????

arnelgp
09-06-2021, 05:46 PM
there is a sample of what you like here?
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.motioneffect

John Wilson
09-09-2021, 01:21 AM
You are trying to do something which is very difficult! Do you have a good knowledge of vba?

Anyway here are some hints.#

#1 start by adding a motion path NOT a custom animation
#2 use a VML path not move To etc and change the path of the animation added.

EXAMPLE to move in rectangle shape


Sub RECT()
Dim oeff As Effect
Dim oshp As Shape
Set oshp = ActiveWindow.Selection.ShapeRange(1)
'add existing motion path type
Set oeff = ActivePresentation.Slides(1).TimeLine.MainSequence.AddEffect(oshp, msoAnimEffectPathRight)
'Adapt opath
oeff.Behaviors(1).MotionEffect.Path = "M 0.0000,0.0000 L 0.2000 0.0000 L 0.2000 0.2000 L 0.0000 0.2000 L 0.0000 0.0000 Z"
End Sub


Explaination of Path

M 0.0000 0.0000 Motion Path from current position
L 0.2000 0.0000 Move in Line .2 of slide width right
L 0.2000 0.2000 Line to .2 of slide width across and .2 of slide height down
L 0.0000 0.2000 Line to original left position and .2 of slide height down
L 0.0000 0.0000 Back to start


If you can't' work out how to apply it to another shape I'm afraid you are on your own! I don't have time to do it for you

papuapu
09-09-2021, 05:37 AM
Thanks Sir

Got the idea. But its very difficult for me to implement in other Powerpoint shape.