How to Loop a PowerPoint Presentation in C#, VB.NET

A looping slideshow displays each slide automatically for a certain amount of time. Once the slideshow reaches the end, it repeats from the beginning. This article will introduce how to programmatically set a PowerPoint document to keep looping when presenting.

Code Snippet:

Step 1: Initialize an instance of Presentation class. Load a sample PowerPoint document to it.

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pptx");

Step 2: Set the Boolean value of ShowLoop as true, which makes the slideshow repeat with continuous looping.

ppt.ShowLoop = true;

Step 3: Set the PowerPoint document to show animation and narration. Use slide transition timings to advance slide.

ppt.ShowAnimation = true;
ppt.ShowNarration = true;
ppt.UseTimings = true;

Step 4: Save the file.

ppt.SaveToFile("LoopEnding.pptx", FileFormat.Pptx2010);

Full Code:

[C#]
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pptx");

ppt.ShowLoop = true;
ppt.ShowAnimation = true;
ppt.ShowNarration = true;
ppt.UseTimings = true;

ppt.SaveToFile("LoopEnding.pptx", FileFormat.Pptx2010);
[VB.NET]
Dim ppt As New Presentation()
ppt.LoadFromFile("C:\Users\Administrator\Desktop\sample.pptx")

ppt.ShowLoop = True
ppt.ShowAnimation = True
ppt.ShowNarration = True
ppt.UseTimings = True

ppt.SaveToFile("LoopEnding.pptx", FileFormat.Pptx2010)