Apply Animations to Text in PowerPoint in C#, VB.NET

2019-03-19 06:46:28 Written by  support iceblue
Rate this item
(0 votes)

To emphasize the text on a shape, we can only animate text instead of the whole shape. This article demonstrates how to apply animations to text in PowerPoint using Spire.Presenstation with C# and VB.NET.

Code Snippets

[C#]
//create a PowerPoint document
Presentation ppt = new Presentation();

//get the first slide
ISlide slide = ppt.Slides[0];

//add a shape to the slide
IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 200, 80));
shape.Fill.FillType = FillFormatType.Solid;
shape.Fill.SolidColor.Color = Color.Purple;
shape.ShapeStyle.LineColor.Color = Color.White;
shape.AppendTextFrame("Welcome to download Spire.Presentation");

//apply animation to the text in shape
AnimationEffect animation = shape.Slide.Timeline.MainSequence.AddEffect(shape, AnimationEffectType.Float);
animation.SetStartEndParagraphs(0, 0);

//save to file
ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);
ppt.Dispose();
[VB.NET]
'create a PowerPoint document
Dim ppt As Presentation =  New Presentation() 
 
'get the first slide
Dim slide As ISlide =  ppt.Slides(0) 
 
'add a shape to the slide
Dim shape As IAutoShape =  slide.Shapes.AppendShape(ShapeType.Rectangle,New RectangleF(50,50,200,80)) 
shape.Fill.FillType = FillFormatType.Solid
shape.Fill.SolidColor.Color = Color.Purple
shape.ShapeStyle.LineColor.Color = Color.White
shape.AppendTextFrame("Welcome to download Spire.Presentation")
 
'apply animation to the text in shape
Dim animation As AnimationEffect =  shape.Slide.Timeline.MainSequence.AddEffect(shape,AnimationEffectType.Float) 
animation.SetStartEndParagraphs(0, 0)
 
'save to file
ppt.SaveToFile("result.pptx", FileFormat.Pptx2013)
ppt.Dispose()

Output

Apply Animations to Text in PowerPoint in C#, VB.NET

Additional Info

  • tutorial_title:
Last modified on Tuesday, 27 August 2024 07:39