ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exception from HRESULT: 0x800A03EC when setting string in Range.Value2 field (https://www.excelbanter.com/excel-programming/384951-exception-hresult-0x800a03ec-when-setting-string-range-value2-field.html)

[email protected]

Exception from HRESULT: 0x800A03EC when setting string in Range.Value2 field
 
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


Madhan

Exception from HRESULT: 0x800A03EC when setting string in Range.Va
 
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.

" wrote:

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




All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com