Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error HRESULT E_FAIL has been returned from a call to a COM component while opening a powerpoint document using C#

Trying to cope up with HRESULT E_FAIL error that I keep getting while trying to open a powerpoint file. There is more to code but the very basic operation for which I get the error is shown in the code block below. Reference DLLs being used are: Office 14.0.0 and 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);

It's a very basic operation, but not sure why it's complaining about the COM Exception. Microsoft Office 2010 32-bit with Service Pack 1 is installed on the machine.

like image 687
phoenix Avatar asked Nov 13 '22 01:11

phoenix


1 Answers

I had the same exact problem. I have searched for the solution for a few day. At last I found it.

When you install MS Office 2010, you should install "Office Shared Features" with Powerpoint in Office CD together. After installing "Office Shared Features", everything is OK.

like image 61
user3312988 Avatar answered Nov 14 '22 23:11

user3312988