Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add Slide Transition in PowerPoint using C#
// Instantiate Presentation class that represents a presentation file
using (Presentation pres = new Presentation("BetterSlideTransitions.pptx"))
{
// Apply circle type transition on slide 1
pres.Slides[0].SlideShowTransition.Type = TransitionType.Circle;
// Set the transition time of 3 seconds
pres.Slides[0].SlideShowTransition.AdvanceOnClick = true;
pres.Slides[0].SlideShowTransition.AdvanceAfterTime = 3000;
// Apply comb type transition on slide 2
pres.Slides[1].SlideShowTransition.Type = TransitionType.Comb;
// Set the transition time of 5 seconds
pres.Slides[1].SlideShowTransition.AdvanceOnClick = true;
pres.Slides[1].SlideShowTransition.AdvanceAfterTime = 5000;
// Apply zoom type transition on slide 3
pres.Slides[2].SlideShowTransition.Type = TransitionType.Zoom;
// Set the transition time of 7 seconds
pres.Slides[2].SlideShowTransition.AdvanceOnClick = true;
pres.Slides[2].SlideShowTransition.AdvanceAfterTime = 7000;
// Save presentation
pres.Save("SampleTransition_out.pptx", SaveFormat.Pptx);
}
// Load PowerPoint presentation
using (Presentation presentation = new Presentation("presentation.pptx"))
{
// Add morph transition
presentation.Slides[0].SlideShowTransition.Type = TransitionType.Morph;
((IMorphTransition)presentation.Slides[0].SlideShowTransition.Value).MorphType = TransitionMorphType.ByWord;
// Save presentation
presentation.Save("presentation-out.pptx", SaveFormat.Pptx);
}
// Instantiate Presentation class to load the source presentation file
using (Presentation presentation = new Presentation("AccessSlides.pptx"))
{
// Apply circle type transition on slide 1
presentation.Slides[0].SlideShowTransition.Type = TransitionType.Circle;
// Apply comb type transition on slide 2
presentation.Slides[1].SlideShowTransition.Type = TransitionType.Comb;
// Save the presentation
presentation.Save("SampleTransition_out.pptx", SaveFormat.Pptx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment