Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 6, 2021 14:31
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/f122aab627a2b7b58544894c52d9935b to your computer and use it in GitHub Desktop.
Save aspose-com-gists/f122aab627a2b7b58544894c52d9935b to your computer and use it in GitHub Desktop.
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