Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active August 21, 2021 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/8f5af8ca6f64c4af2dc29674b5fb0e97 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/8f5af8ca6f64c4af2dc29674b5fb0e97 to your computer and use it in GitHub Desktop.
Apply Animation Effects to Text in PowerPoint using C#
// Load presentation
using (Presentation presentation = new Presentation("Presentation.pptx"))
{
// Select paragraph to add effect
IAutoShape autoShape = (IAutoShape)presentation.Slides[0].Shapes[0];
IParagraph paragraph = autoShape.TextFrame.Paragraphs[0];
// Add Fly animation effect to selected paragraph
IEffect effect = presentation.Slides[0].Timeline.MainSequence.AddEffect(paragraph, EffectType.Fly, EffectSubtype.Left, EffectTriggerType.OnClick);
// Save presentation
presentation.Save("AnimationEffectinParagraph.pptx", SaveFormat.Pptx);
}
// Load presentation
using (Presentation pres = new Presentation("Presentation.pptx"))
{
// Get sequence and shape from slide
ISequence sequence = pres.Slides[0].Timeline.MainSequence;
IAutoShape autoShape = (IAutoShape)pres.Slides[0].Shapes[1];
// Loop through the paragraphs
foreach (IParagraph paragraph in autoShape.TextFrame.Paragraphs)
{
// Access animation effects
IEffect[] effects = sequence.GetEffectsByParagraph(paragraph);
if (effects.Length > 0)
Console.WriteLine("Paragraph \"" + paragraph.Text + "\" has " + effects[0].Type + " effect.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment