views:

76

answers:

2

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

    activeSlide.TimeLine.InteractiveSequences.Add().AddTriggerEffect(
        textBox2,
        MsoAnimEffect.msoAnimEffectFade,
        MsoAnimTriggerType.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?

+1  A: 

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.

ktharsis
You cant foreach the office objects and then delete, so I found out of experience. You have to for loop
alex
+1  A: 

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();
                }
            }
        }
    }
alex
Hey Alex, good to see this resolved. You can accept your own answer by clicking on the hollow checkmark next to your answer.
Otaku