将powerpoint幻灯片转换为图像文件,无需打开powerpoint窗口

本文关键字:powerpoint 窗口 文件 幻灯片 转换 图像 | 更新日期: 2023-09-27 18:12:56

我的程序应该将ppt幻灯片转换为图像文件,它确实做到了。唯一让我困扰的是空白的PowerPoint窗口打开又关闭(有声音)。是否可以在不打开此窗口的情况下执行此转换?

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);
                }

将powerpoint幻灯片转换为图像文件,无需打开powerpoint窗口

您正在将pptApp的Visible属性设置为true。这会导致你所看到的问题吗?