Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Excel interop from c#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Velislav - 14 Feb 2007 15:21 GMT
Hi, hope you can shed some light.

I have a C# app which does some Excel interop. I didn't write the app
and I got e-mailed the executable which is used in production.

I then went and found the source code for it.

Now this thing directly references a Excel.dll (version 1.2.0.0) and
there's also an Office.dll (version 2.2.0.0), which I assume is used
by the Excel dll.

Same scenario with the project file.

When I run the production executable, it works just fine and dandy.

However, when I run the app from Visual Studio (this is 2003 - .NET
1.1), it throws the wonderful error "Exception from HRESULT:
0x800A03EC." when the following code runs:

System.Reflection.Missing missing = System.Reflection.Missing.Value;
Excel.Application app = new Excel.ApplicationClass();
workbook =
app.Workbooks.Open(fileName,updateLinks,readOnly,missing,missing,missing,true,missing,missing,missing,missing,missing,false);

After some extensive googling I have found that the most common cause
for this is a US English version of Office running on a non-US English
version of Windows (mine is South African English). So I promtly
changed my regional settings to US-English, I even programatically
changed the thread's CultureInfo to en-US, as explained somewhere on
MSDN. Still I get the error.

I tried changing the references in the project to the interop dlls in
the GAC, still nothing.

There are a few other COMException error descriptions which correspond
to the same HRESULT, which to me is a bit puzzling, but anyway, that's
the most detailed error description I get... "Exception from HRESULT:
0x800A03EC."

I am sitting here pulling my hair out... if anyone has any idea what's
up... I would be eternally grateful...

Cheers!
Madhan - 14 Feb 2007 16:20 GMT
Hi, in Visual Studio, there is a place wherein you can reference DLLs of
external applications such as Word, Excel etc... In my opinion, you may have
to set the reference to Excel related objects/dlls so that the Visual Studio
recognizes it.

> Hi, hope you can shed some light.
>
[quoted text clipped - 39 lines]
>
> Cheers!
Velislav - 14 Feb 2007 17:44 GMT
> Hi, in Visual Studio, there is a place wherein you can reference DLLs of
> external applications such as Word, Excel etc... In my opinion, you may have
> to set the reference to Excel related objects/dlls so that the Visual Studio
> recognizes it.

Hi Madhan, yeah I have a reference to *some* Excel interop assembly, I
have access to all the classes, i can instantiate objects and call
their methods. the problem is not visibility. The problem is either in
referencing the wrong version of the dll (I suspect when the app was
written it was using office 2000 or office XP and on my development
machine I'm running office 2003) or my windows/office/visual studio
setup.

I hope we're on the same page here :) Thanks for your input.
Velislav - 15 Feb 2007 07:39 GMT
OK, I found *my* problem, it seems quite app-specific, so probably
won't be helpful to others getting this mysterious error code.

Here's what's happening - the app copies a template XLS file with a
new name to a given output location. This new name is determined by
the code, and it appears in some instances it can be " ", resulting in
the template being copied to something like "C:\Location\ .xls".
Which, seems to be a valid windows filename, however, when i try to
open the file with the Excel interop code, it throws the error.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.