试图解决我在尝试打开 powerpoint 文件时不断遇到的 HRESULT E_FAIL 错误。还有更多的代码,但我得到错误的非常基本的操作显示在下面的代码块中。使用的参考 DLL 为:Office 14.0.0 和 Microsoft.Office.Interop.Powerpoint 14.0.0。
Application application = new Application { DisplayAlerts = PpAlertLevel.ppAlertsNone };
Presentation powerpoint = application.Presentations.Open(@"X:\XXX\xxx.pptx");
powerpoint.SaveAs(@"X:\XXX\saved.pdf", PpSaveAsFileType.ppSaveAsPDF, MsoTriState.msoTrue);
这是一个非常基本的操作,但不确定为什么它会抱怨 COM 异常。机器上安装了带有 Service Pack 1 的 Microsoft Office 2010 32 位。