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

2016-08-18 06:46:17 Written by  support iceblue
Rate this item
(0 votes)

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#]
using Spire.Presentation;
namespace LoopPPT
{
    class Program
    {
        static void Main(string[] args)
        {
            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]
Imports Spire.Presentation
Namespace LoopPPT
	Class Program
		Private Shared Sub Main(args As String())
			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)
		End Sub
	End Class
End Namespace

Additional Info

  • tutorial_title: Loop a PowerPoint Presentation in C#, VB.NET
Last modified on Friday, 24 September 2021 09:11