Search code examples
c#ms-officepowerpointoffice-interop

Convert powerpoint slide into an image file, without opening the powerpoint window


My program should convert a ppt slide into an image file and it does. The only thing that bothers me is the blank PowerPoint window that opens and closes again (with sound). Is it possible to perform this conversion without opening this window?

if (Path.GetExtension(file).Contains("ppt"))
                {
                    PPT.Application pptApp = new PPT.Application();
                    pptApp.Visible = MsoTriState.msoTrue;
                    PPT.Presentation pptPr = pptApp.Presentations.Open(file, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
                    pptPr.Slides[1].Export(ImagePath + Path.GetFileNameWithoutExtension(file) + ".png", "png");
                    pptPr.Close();
                    pptApp.Quit();
                    Marshal.ReleaseComObject(pptPr);
                    Marshal.ReleaseComObject(pptApp);
                }

Solution

  • You are setting the pptApp's Visible property to true. Could that be causing the issue you're seeing?