Add animation programatically?
-
miércoles, 23 de mayo de 2012 9:10
Dear,
How can I assign an animation to an object on the slide programatically?
Thx
3D Interactive Simulations And Web Developer
- Cambiado Cindy Meister MVPMVP, Moderator miércoles, 23 de mayo de 2012 13:28 PowerPoint-specific (From:Visual Studio Tools for Office)
Todas las respuestas
-
jueves, 24 de mayo de 2012 7:26Moderador
Hi Hassan,
Thanks for posting in the MSDN Forum.
Following is a sample which will let the shape fly form the top.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Tools.Ribbon; using PowerPoint = Microsoft.Office.Interop.PowerPoint; namespace PowerPointAddIn9 { public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void button1_Click(object sender, RibbonControlEventArgs e) { PowerPoint.Application ppApp = Globals.ThisAddIn.Application; PowerPoint.Presentation ppP = ppApp.ActivePresentation; PowerPoint.Slide ppS = ppP.Slides[1]; PowerPoint.ShapeRange sr = ppS.Shapes.Range(1); sr.AnimationSettings.AdvanceMode = PowerPoint.PpAdvanceMode.ppAdvanceOnTime; sr.AnimationSettings.AdvanceTime = 1; sr.AnimationSettings.Animate = Microsoft.Office.Core.MsoTriState.msoTrue; sr.AnimationSettings.EntryEffect = PowerPoint.PpEntryEffect.ppEffectFlyFromTop; } } }I hope it can help you.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Marcado como respuesta Hassan Ayoub viernes, 25 de mayo de 2012 2:08
-
viernes, 25 de mayo de 2012 2:40Tried it but didn't worked!!!!
3D Interactive Simulations And Web Developer
-
viernes, 25 de mayo de 2012 2:51Moderador
Hi Hassan,
It's based on my experience that not all of the PowerPoint.PpEntryEffect will fit Shape object. You need do some test for this enmu.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
-
sábado, 26 de mayo de 2012 14:41
Ok, will tyr other animations, but how to assign an animation to the selected shape by mouse?
Thx
3D Interactive Simulations And Web Developer
-
miércoles, 30 de mayo de 2012 23:52
Hi Tom,
I wouldn't recommend this as a solution. The solution uses a legacy object AnimationSettings which is just around to provide backward compatibility with older versions of PowerPoint. Also, using it can sometimes even remove existing animations. It is best to use the Timeline object to assign animations. Here is some information though it is pertaining to VBA - http://skp.mvps.org/ppttimeline1.htm
Regards, Shyam (http://skp.mvps.org)

