开发者

PowerPoint Programmatically find and delete animation/effect

I have programmatically (VSTO) added animations to the PowerPoint slide using the following code

    activeSlide.TimeLine.InteractiveSequences.Add().AddTriggerEffect(
        textBox2,
        MsoAnimEffect.msoAnimEffectFade,
        MsoAnimTri开发者_如何学编程ggerType.msoAnimTriggerOnMediaBookmark,
        selectedShape,
        "Bookmark A",
        MsoAnimateByLevel.msoAnimateLevelNone);   

    activeSlide.TimeLine.InteractiveSequences.Add().AddTriggerEffect(
        textBox2,
        MsoAnimEffect.msoAnimEffectFade,
        MsoAnimTriggerType.msoAnimTriggerOnMediaBookmark,
        selectedShape,
        "Bookmark B",
        MsoAnimateByLevel.msoAnimateLevelNone).Exit = MsoTriState.msoTrue;

So how would I go about deleting the animation without deleting textBox2? Is there a way to traverse through the animations and find the ones I need to delete which are associated with textBox2?


Thanks to Shyam Pillai for the answer, I translated his vba code as follows:

    private void DeleteAnnimations(Slide slide, Shape shape)
    {
        for (int i = slide.TimeLine.InteractiveSequences.Count; i >= 1; i--)
        {
            Sequence sequence = slide.TimeLine.InteractiveSequences[i];
            for (int x = sequence.Count; x >= 1; x--)
            {
                Effect effect = sequence[x];
                if (effect.Timing.TriggerType == MsoAnimTriggerType.msoAnimTriggerOnMediaBookmark)
                {
                    if (effect.Shape.Name == shape.Name)
                        effect.Delete();
                }
            }
        }
    }


Forgive me because I don't have PPT 2010 handy (you should note in your question it is that version) but this should get you started in the right direction.

InteractiveSequences is a collection of Sequence objects
Sequence object is really a collection of Effect objects
Effect objects have a Shape property

foreach (Sequence seq in activeSlide.TimeLine.InteractiveSequences)
  foreach (Effect eff in seq)
    if (eff.Shape == "target shape")
      ...

I believe there is a remove or maybe a delete function for the Effect object itself.


it's simply deleting the animation without deleting textbox:

dim osh as shape

set osh = .....

oSh.AnimationSettings.Animate = 0 => deleting the animation of osh 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜