6

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.

3
  • Have you tried to google for "powerpoint 0x80004005"? The most common mistake seems to be that someone tries to use Office interop from ASP.NET (which is already a big mistake by itself) and the ASP.NET process/user misses the rights to access the file. Commented Jul 25, 2013 at 5:38
  • did you try to selecting 'No Authentication Required' from 'Network DTC Access'...?? Commented Sep 19, 2013 at 5:36
  • Did you ever find a root cause answer for this? I have a test cases where this error occurs on the second call to .Open, even though all of the VSTO/COM objects are being released (refcount = 0) between the two calls. Commented Jul 8, 2016 at 17:32

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I was also facing the same problem and as suggested above after installing "Office Shared Features" it worked.
Had to register an account and stop lurking just to also state that reinstalling Office with the "Office Shared Features" fixes the problems. Also as some have commented but I am confirming, you do not need to open the ppt in visible mode once this feature is included. (Office 2010) Please upvote the guys answer as it's not at the top of this thread which it should be.
Unfortunately that wasn't my problem, everything is installed in Microsoft Office\Office Shared Features
0

Powerpoint needs to be visible before it can open a presentation. Right after creating the new Application object call this:

application.Visible = MsoTriState.msoTrue;

If this still doesn't resolve the exception you'll have to post more details about the exception. Somewhere in it's properties (or maybe inner exceptions) it should say what exactly failed.

6 Comments

Well that's the point of it. It never provides any clear exceptions. I have been using at least this basic code for quite some time to do complex stuff with the presentations like removing metadata information or saving it as a different format. The snippet is very basic to open a presentation regardless of making application visible or not. This error has no description, inner exception is null. Not sure if the there is a problem with the Office application installed on the machine or the service pack that I recently added?
The exact error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL h as been returned from a call to a COM component. at Microsoft.Office.Interop.PowerPoint.Presentations.Open(String FileName, Ms oTriState ReadOnly, MsoTriState Untitled, MsoTriState WithWindow)
FWIW, Powerpoint does not need to be visible in order to open presentations, so long as you open the presentations w/o a window. Does the problem occur on all files or only some? What happens if you manually try to open the same files in PPT?
@SteveRindsberg To open a presentaion without a window you have to specify the WithWindow parameter in the Open call with value MsoTriState.msoFalse. Since the code in the question doesn't include this parameter I assumed that he want to have a visible window.
Both of you stand with valid points. @Steve - I have tried with all the files. The problem is with all the files - I have tried with all formats of files such as ppt/pptx/pptm - also when tried manually files open up fine. I have tried re-installing Office 2010 - made sure that all components including VBA components are installed properly. Also made sure that VSTO is installed properly. The code launches the application alright but just fails to open a file. I am sure something has messed up the registry settings - so I'm just validating the settings. I'll keep you updated.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.