Add Slide Transitions in PowerPoint Presentations using C#

Slide transitions are the visual effects that appear when you move from one slide to another in PowerPoint presentations. Moreover, you can set transition sound, speed, duration, and other effects as per your choice. In this article, you will learn how to add slide transitions in PowerPoint presentations programmatically using C#.

.NET API to Add Slide Transitions in PowerPoint

In order to add transitions to the slides in PowerPoint presentations, we will use Aspose.Slides for .NET. It is a .NET API to create and manipulate the PowerPoint and OpenOffice documents. You can either download the API or install it using NuGet.

PM> Install-Package Aspose.Slides.NET

Add Slide Transition using C#

The following are the steps to add slide transition in a PowerPoint presentation using C#.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Then, set a slide transition type using SlideShowTransition.Type property and TransitionType enum.
  3. Finally, save the updated presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to set the transition of a slide in a PowePoint presentation.

Add Advanced Slide Transitions using C#

The following are the steps to set advanced slide transition options such as duration, sound, speed, etc.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Set a slide transition type using SlideShowTransition.Type property and TransitionType enum.
  3. Set a advanced effects such as SlideShowTransition.Sound, SlideShowTransition.AdvanceAfterTime, etc. (see list of effects).
  4. Finally, save the updated presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to set advanced slide transition options in a PowerPoint presentation.

Set Morph Transition in PowerPoint using C#

Using Aspose.Slides for .NET, you can also set the morph transitions, which are used to make smooth animations. The following morph transitions are supported by the API:

  • ByObject: Morph transition will be performed considering shapes as indivisible objects.
  • ByWord: Morph transition will be performed with transferring text by words where possible.
  • ByChar: Morph transition will be performed with transferring text by characters where possible.

The following are the steps to add morph transition in a PowerPoint presentation using C#.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Set SlideShowTransition.Type property to TransitionType.Morph.
  3. Set morph transition type using ((IMorphTransition)presentation.Slides[0].SlideShowTransition.Value).MorphType property.
  4. Finally, save the updated presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to set morph transitions in a PowerPoint presentation.

Get a Free API License

You can use Aspose.Slides for .NET without evaluation limitations by requesting a temporary license.

Conclusion

In this article, you have learned how to add slide transitions in PowerPoint presentations using C#. Moreover, you have seen how to set morph transitions in the slides programmatically. In addition, you can visit the documentation to explore other features of API. Also, you can feel free to let us know about your queries via our forum.

See Also