Exception from HRESULT: 0x800A03EC when setting string in Range.Value2 field

A

amit.nayar

I am trying set a string in a range programmatically using C#. Here's
the code:

string str = @"= (Beginning Stockholders' Equity + Ending
Stockholders' Equity) / 2";
range.Value2 = str;

Assume that range is a valid range. I don't want to bore you with all
the code, as showing you how to get a range from a spreadsheet seems
like useless information.

When I execute this code, I get the following exception:

System.Runtime.InteropServices.COMException : Exception from HRESULT:
0x800A03EC

I realize the string looks like a formula, and it is not a valid
formula, but why does this throw an exception? I'm able to type this
string into Excel. I've also tried to set the Range.Formula and the
Range.Value to no avail.

Any help would be great. Thanks in advance for your help.

Cheers,
Amit
 
M

Madhan

Hi, in my opinion there is no concatenation operator between the @ symbol and
the " symbol in the first line or you have placed the @ symbol outside "
accidentally. Try fixing that. Also, in my opinion, ' symbol should be
preceeded by a \ symbol to make it an ordinary string. I hope this helps you.
 

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