Friday, August 21, 2009

HRESULT E_FAIL PowerPoint Solution

I was looking into developing some Office utilities using their DLLs, and for starters--creating a tool for generating PowerPoint presentations from an image directory using C#.

But when I ran this code:
ApplicationClass powerpoint = new ApplicationClass();
Presentation ppt = powerpoint.Presentations.Add(MsoTriState.msoFalse);
I got this exception:
Error HRESULT E_FAIL has been returned from a call to a COM component
I've been looking for an answer for a while (for at least 10 minutes!) when it was finally time to ask it in a forum.

So thanks to this post I found out that you must install the Visual Basic for Applications from the Microsoft Office CD in order to actually use the DLLs Microsoft supplies:



This solution also applies for developing with other Office products such as Word, Outlook and others.

1 comments:

  1. This sometimes happened when a "not implemented" exeption was thrown as well.

    ReplyDelete