How to hide slide in PowerPoint document in C#, VB.NET

Hide slide is one of the useful features in Microsoft PowerPoint, which enables lecturers to hide the slide that they don't want to present to audiences without deleting it.

How to achieve this function programmatically? This article will demonstrate how to hide slide in PowerPoint document with Spire.Presentation in C#, VB.NET.

Before start, please download Spire.Presentation and install it correctly, then add the.dll file from Bin folder as the reference of your project.

This is the screenshot of the Source PowerPoint document:

How to hide slide in PowerPoint document in C#, VB.NET

Follow the detail steps below:

Step 1: create a new presentation.

Presentation presentation = new Presentation();

Step 2: load the sample document.

presentation.LoadFromFile("sample slide.pptx");

Step 3: hide the second slide and save the target file as HiddenSlide.pptx.

presentation.Slides[1].Hidden = true;
presentation.SaveToFile("HiddenSlide.pptx", FileFormat.Pptx2007);

Screenshot after hiding:

How to hide slide in PowerPoint document in C#, VB.NET

Full codes:

[C#]
using Spire.Presentation;

namespace hide_slide
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("sample slide.pptx");
            presentation.Slides[1].Hidden = true;
            presentation.SaveToFile("HiddenSlide.pptx", FileFormat.Pptx2007);
        }
    }
}
[VB.NET]
Imports Spire.Presentation
Namespace hide_slide
	Class Program
		Private Shared Sub Main(args As String())
			Dim presentation As New Presentation()
			presentation.LoadFromFile("sample slide.pptx")
			presentation.Slides(1).Hidden = True
			presentation.SaveToFile("HiddenSlide.pptx", FileFormat.Pptx2007)
		End Sub
	End Class
End Namespace