Excel interop from c#

V

Velislav

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!
 
M

Madhan

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.
 
V

Velislav

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.
 
V

Velislav

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top