How to convert PowerPoint to PPTX in C#?

PPT is the file format used by Microsoft PowerPoint Presentation 97 - 2003, while PPTX is created by PowerPoint Presentation 2007, 2010. PPTX file format enjoys the advantages of smaller size, higher security, and higher integration with other file formats. But the Microsoft Office version under 2007 cannot open PPTX PowerPoint presentation directly. This article will show you how to convert PPT file format to PPTX in C# with only three lines of code.

Make sure Spire.Presentation for .NET has been installed correctly and then add Spire.Presentation.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Presentation\Bin\NET4.0\ Spire. Presentation.dll". Here comes to the details of how to output PPT to PPTX:

Step 1: Create a presentation document.

Presentation presentation = new Presentation();

Step 2: Load the PPT file from disk.

presentation.LoadFromFile(@"..\..\..\..\..\..\Data\sample4.ppt");

Step 3: Save the PPT document to PPTX file format.

presentation.SaveToFile("ToPPTX.pptx", FileFormat.Pptx2010);

Step4: Launch and view the resulted PPTX file.

System.Diagnostics.Process.Start("ToPPTX.pptx");

Full codes:

namespace Spire.Presentation.Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnRun_Click(object sender, EventArgs e)
        {
            //create PPT document
            Presentation presentation = new Presentation();

            //load the PPT file from disk
            presentation.LoadFromFile(@"..\..\..\..\..\..\Data\sample4.ppt");

            //save the PPT document to PPTX file format
            presentation.SaveToFile("ToPPTX.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("ToPPTX.pptx");
        }
    }
}

Target screenshot:

Convert PPT to PPTX