Back to Devexpress

DevExpress Presentation API Library: Manage Slides

officefileapi-405417-presentation-api-slides-manage-slides.md

latest6.9 KB
Original Source

DevExpress Presentation API Library: Manage Slides

  • Nov 07, 2025
  • 4 minutes to read

The DevExpress Presentation API library allows you to perform various tasks with slides: add new slides to a presentation, modify existing slides, duplicate and merge slides, and much more.

To get more information on how to create or load presentations, refer to the following help topic: DevExpress Presentation API Library: Create, Load, and Save Presentations.

Access Presentation Slides

Use the Presentation.Slides property to access the collection of slides within the presentation.

csharp
using DevExpress.Docs.Presentation;

    // Load a presentation from a local PPTX file:
    Presentation presentation = new Presentation(File.ReadAllBytes(@"D:\testpresentation.pptx"));

    // Access the first slide in the presentation:
    var slide = presentation.Slides[0]
vb
Imports DevExpress.Docs.Presentation

    ' Load a presentation from a local PPTX file:
    Dim presentation As New Presentation(File.ReadAllBytes("D:\testpresentation.pptx"))

    ' Access the first slide in the presentation:
    Dim slide As Slide = presentation.Slides(0)

Add a Slide

Follow the steps below to add a slide to the presentation’s Slides collection:

  • Create a Slide object. Specify a layout type in the constructor.

  • Call the Add or Insert method to add the newly created slide to the presentation.

  • C#

  • VB.NET

csharp
using DevExpress.Docs.Presentation;

    Presentation presentation = new Presentation();
    Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
    presentation.Slides.Add(slide);
vb
Imports DevExpress.Docs.Presentation

    Dim presentation As New Presentation()
    Dim slide As New Slide(New SlideLayout(SlideLayoutType.Blank, "slide"))
    presentation.Slides.Add(slide)

Create and Add a Slide Based on a Slide Master

The Slide Master is a template slide that you can use as a base for other slides. Presentation API distributes slide master content — such as shapes, layouts, and text styles — across all slides created from it. Changes made to the slide master are immediately applied to all its descendant slides.

Slide masters contain layout presets used to organize content placeholders on a slide. Call the slide master’s Layouts.Get method to obtain a layout of the specified type. You can also call the Layouts.GetOrCreate method to obtain a layout. If the requested layout does not exist, it is automatically created.

csharp
using DevExpress.Docs.Presentation;

    Slide slide = new Slide(presentation.SlideMasters[0].Layouts.Get(SlideLayoutType.Title));
    presentation.Slides.Add(slide);
vb
Imports DevExpress.Docs.Presentation

    Dim slide As New Slide(presentation.SlideMasters(0).Layouts.Get(SlideLayoutType.Title))
    presentation.Slides.Add(slide)

For more information about slide masters, refer to the following help topic: DevExpress Presentation API Library: Configure Slide Masters and Layouts.

Manage Slide Visibility

The Visible property indicates whether the slide is visible.

The following code snippet removes invisible slides from the presentation:

csharp
foreach (Slide slide in presentation.Slides) {
    if (!slide.Visible) {
        presentation.Slides.Remove(slide);
    }
}
vb
For Each slide As Slide In presentation.Slides
    If Not slide.Visible Then
        presentation.Slides.Remove(slide)
    End If
Next

Duplicate Slides

Call a slide’s Clone method to create this slide’s copy. Then you can use this copy as a base for another slide:

csharp
Slide clonedSlide = slide.Clone();
presentation.Slides.Add(clonedSlide);
vb
Dim clonedSlide As Slide = slide.Clone()
presentation.Slides.Add(clonedSlide)

Reorder Slides

Call the SlideCollection.Move method to rearrange slides within the Presentation.Slides collection.

csharp
presentation.Slides.Move(slide, 1);
presentation.Slides.Move(3, 2);
vb
presentation.Slides.Move(slide, 1)
presentation.Slides.Move(3, 2)

Copy Slides from Another Presentation

The following code snippet adds slides to a presentation from another presentation to merge two presentations:

csharp
Presentation presentation1 = new Presentation(File.ReadAllBytes(@"presentation1.pptx"));
Presentation presentation2 = new Presentation(File.ReadAllBytes(@"presentation2.pptx"));
foreach (Slide slide in presentation2.Slides) { 
    presentation1.Slides.Add(slide);
}
vb
Dim presentation1 As Presentation = New Presentation(File.ReadAllBytes("presentation1.pptx"))
Dim presentation2 As Presentation = New Presentation(File.ReadAllBytes("presentation2.pptx"))

For Each slide As Slide In presentation2.Slides
    presentation1.Slides.Add(slide)
Next

For more examples on how to merge and split presentations, refer to the following help topic: Merge and Split Presentations with the DevExpress Presentation API Library.

Remove Slides

Call the following methods to remove a slide from the presentation:

  • Remove - Removes the given slide object.

  • RemoveAt - Removes the slide with the given index.

  • Clear - Removes all slides from the collection.

  • C#

  • VB.NET

csharp
presentation.Slides.Remove(slide);
presentation.Slides.RemoveAt(0);
presentation.Slides.Clear();
vb
presentation.Slides.Remove(slide)
presentation.Slides.RemoveAt(0)
presentation.Slides.Clear()