以编程方式将对象添加到powerpoint幻灯片强制所有对象动画

时间:2013-05-22 11:56:43

标签: c# .net powerpoint

我正在动态地向PowerPoint幻灯片中添加一些对象以及一些动画。问题是当我在添加第一个对象后添加任何对象时,之前添加的对象和当前对象都带有动画。如何让我之前添加的对象保持不变,只有新的对象带有动画,这里是我正在使用的一些代码,

private void AddShapeToSlide(int left, int top, int width, int height)
{
    Slide slide = GetCurrentSlide();
    Shape shape = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, left, top, width, height);
    ApplyAnimation(slide, shape);
    shape.ZOrder(MsoZOrderCmd.msoBringToFront);
    _presentation.SlideShowWindow.Activate();
}

private void ApplyAnimation(Slide slide, Shape shape)
{
    shape.AnimationSettings.AdvanceMode = PpAdvanceMode.ppAdvanceOnTime;
    shape.AnimationSettings.AdvanceTime = 0;
    shape.AnimationSettings.Animate = MsoTriState.msoTrue;
    shape.AnimationSettings.EntryEffect = GetPowerPointTransition();

    Effect effect = slide.TimeLine.MainSequence.FindFirstAnimationFor(shape);
    if (effect != null && shape.AnimationSettings.EntryEffect != PpEntryEffect.ppEffectNone)
    {
         effect.Timing.Duration = 5;
    }
}

任何帮助或想法都很有价值。在此先感谢。

0 个答案:

没有答案