Convert PowerPoint Presentation to HTML with Office 2019 or Office 365

387 Views Asked by At

I have a code which converts the PowerPoint presentation to HTML using Office 2007. The code which runs on Office 2007 without a problem is as below:

     static void Main(string[] args)
        {
            string source = "C:\\Temp\\testPPTX.pptx";
            string tempFile = "C:\\Temp\\mytest.html";

            Application app = new Application();
            Presentation presentation = app.Presentations.Open(source, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);

            // Save the presentation as HTML
            presentation.SaveAs(tempFile, PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTriStateMixed);

            // Close the presentation and quit PowerPoint
            presentation.Close();
            app.Quit();

            Console.WriteLine("Conversion completed.");
        }

When I run the above code in the higher Office version such as Office 2019 or Office 365, I receive an error:

System.Runtime.InteropServices.COMException: 'Presentation (unknown member) : Invalid request. Saving as an HTML presentation is not supported in this version of PowerPoint.'

enter image description here

Is there a way to convert the PowerPoint presentation HTML using the above code?

1

There are 1 best solutions below

2
On

As a possible workaround you can save slides as images and then construct the result HTML page based on these images. See Slide.Export method which exports a slide, using the specified graphics filter, and saves the exported file under the specified file name.