c#将.ppt转换为图像

本文关键字:图像 转换 ppt | 更新日期: 2023-09-27 17:54:38

我正在尝试使用c#将。ppt文件转换为图像集合。

我使用以下代码:

using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
.....
Microsoft.Office.Interop.PowerPoint.Application app = new Microsoft.Office.Interop.PowerPoint.Application();
Presentation pres = app.Presentations.Open(@"C:'Users'XYZ'Desktop'Presentation.ppt", MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
pres.SaveAs(@"C:'Users'XYZ'Desktop'", PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoFalse);
pres.Close();

我得到以下异常:

为CLSID为{91493441-5A91-11CF-8700-00AA0060263B}的组件检索COM类工厂失败,原因是以下错误:80040154类未注册(异常来自HRESULT: 0x80040154 (regdbe_classnotreg))。

Microsoft.Office.Interop.PowerPoint.Application app = 
                      new Microsoft.Office.Interop.PowerPoint.Application();

是否有必要安装完整版本的Office 2010以使此代码工作(我只安装了Powerpoint查看器),或者是否有其他解决方案来解决此例外?

c#将.ppt转换为图像

您需要安装完整的PowerPoint才能实现这一点。查看器无法操作powerpoint文件。