error 0x800A03EC - why?

D

David Thielen

When calling the code below we get an Exception "Exception from HRESULT:
0x800A03EC". It cannot be a R/O issue because the user can edit & save the
spreadsheet. It cannut be the language version mis/match because we get an
error much earlier in that case.

Any idea what can cause it? (Note, the methods called in this code do not
call any Excel COM methods so it must be in this code.)

Application excelApp = app.NativeApplication;
Workbook wrkbk = excelApp.ActiveWorkbook;
if (wrkbk == null)
return;

// delete the old Worksheet
Worksheet sheet = FindSheet(wrkbk, "WR_DATA");
if (sheet != null)
{
bool blnAlertStatus = excelApp.DisplayAlerts;
excelApp.DisplayAlerts = false;
sheet.Delete();
excelApp.DisplayAlerts = blnAlertStatus;
}

string data = DocumentDataBuffer.SaveProfileToDoc(app.DocData,
wrkbk.Path == null ? null : wrkbk.FullName);
if (data == null)
return;

// and save it
sheet = (Worksheet) wrkbk.Worksheets.Add(Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
sheet.Name = "WR_DATA";
sheet.Visible = XlSheetVisibility.xlSheetHidden;

// and save it - in blocks if necessary
if (data.Length < BLK_SIZE)
{
Range rng = sheet.get_Range("A1", "A1");
rng.Value2 = data;
}
else
{
int off = 0;
int row = 1;
while (off < data.Length)
{
int len = Math.Min(BLK_SIZE, data.Length - off);
string cellData = data.Substring(off, len);

string loc = "A" + row;
Range rng = sheet.get_Range(loc, loc);
rng.Value2 = cellData;

off += len;
row++;
}
}

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

I have tested your example code. The code itself should be OK. It won't
throw the 0x800A03EC error if we solely run the piece of code. Thus, the
cause of the error depends on when, where and how we execute the code
snippet.

I know some scenarios that can result in the error 0x800A03EC based on my
experience. We can start troubleshooting the problem by checking if the
scenarios below meet your situation:

1. We cannot change the value of a cell as it enters the calculation mode.
Excel is in "Calculation" mode and will not allow the contents of cells to
be changed, otherwise, it will cause a "Calculation Reentrancy" and we may
get the error 800A03EC. An instance of such behavior is, if our automation
add-in exposes a UDF (User Defined Function) that sets the other cells'
values in the UDF definition, the error "800A03EC" will be thrown. E.g. an
UDF defined as this:
public object SetValue(Range r, object val) {
r.set_Value(XLRangeValueDataType.xlRangeValueDefault, val); // we set
the other cells' values in the UDF definition.
}
I recall you once asked me how to expose UDFs in a COM addin, thus, please
check if the example code is called from a UDF.

There are always problem with calculation reentrancy in excel and you need
to be very careful while implementing something that you are trying to
achieve. One solution I could suggest is to create a combination of COM
Add-in and automation add-in, and register an event that handles WorkSheets
"Calculate" event. The calculate event gets called after every
recalculation of the worksheet. Also create a 2D array that will hold all
the ranges and values that needs to be updated after the calculations are
done. When the UDF (user defined function) =SetValue() gets called and once
the calculation is done, the "Calculate" event gets fired. In the event
handler of "calculate" event the COM Add-in will get the values from the 2D
array and fill the appropriate cells with values. This way you can update
the appropriate cells after calculation.

2. Make sure there is only one thread automating Excel
None of the Office applications, Microsoft Excel included, support
reentrancy. Because the second thread is reentering Excel, and because
Excel is in the processing other tasks, e.g. the menu item click, there can
be problems like 800A03EC. The resolution is to move the code to the main
thread and avoid reentrancy.

3. A known issue of Excel 2003 that can cause the error 800A03EC
http://support.microsoft.com/kb/823988

There can be other reasons for the error 0x800A03EC, if none of the above
fits your situation, please give me more information about where, when and
how the example code is called.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

The facility error code messge for the error code "0x800A03EC" is "Invalid
flags", which does not tell any useful information.

Please notify me when you finish the check of the hypotheses.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
C

Charles Chen

Jialiang,

I am also experiencing this error except on CheckOut.

I have a .NET managed add-in for Excel which is throwing the following error
when I make a call to Application.Worksheets.CheckOut("my-url-here"):

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

I'll have to check on the re-entrancy/threading issues, but it's odd that
all of the other API calls which I'm using are working fine (including calls
to CanCheckIn and CheckIn, oddly enough)

I've been struggling with this for some time now. Any additional input
would be much appreciated.
 
N

Nikolay Sonin

I have the same problem with get_Range in .NET VSTO on machine with non-standard regional settings. Did you find the right solution?



CharlesChe wrote:

Jialiang,I am also experiencing this error except on CheckOut.I have a .
30-Apr-08

Jialiang

I am also experiencing this error except on CheckOut

I have a .NET managed add-in for Excel which is throwing the following erro
when I make a call to Application.Worksheets.CheckOut("my-url-here")

System.Runtime.InteropServices.COMException (0x800A03EC): Exception fro
HRESULT: 0x800A03E

I'll have to check on the re-entrancy/threading issues, but it's odd that
all of the other API calls which I'm using are working fine (including calls
to CanCheckIn and CheckIn, oddly enough

I've been struggling with this for some time now. Any additional input
would be much appreciated.

Previous Posts In This Thread:

error 0x800A03EC - why?
When calling the code below we get an Exception "Exception from HRESULT:
0x800A03EC". It cannot be a R/O issue because the user can edit & save the
spreadsheet. It cannut be the language version mis/match because we get an
error much earlier in that case

Any idea what can cause it? (Note, the methods called in this code do not
call any Excel COM methods so it must be in this code.

Application excelApp = app.NativeApplication
Workbook wrkbk = excelApp.ActiveWorkbook
if (wrkbk == null
return

// delete the old Workshee
Worksheet sheet = FindSheet(wrkbk, "WR_DATA")
if (sheet != null

bool blnAlertStatus = excelApp.DisplayAlerts
excelApp.DisplayAlerts = false
sheet.Delete()
excelApp.DisplayAlerts = blnAlertStatus


string data = DocumentDataBuffer.SaveProfileToDoc(app.DocData,
wrkbk.Path == null ? null : wrkbk.FullName)
if (data == null
return

// and save i
sheet = (Worksheet) wrkbk.Worksheets.Add(Type.Missing, Type.Missing,
Type.Missing, Type.Missing)
sheet.Name = "WR_DATA"
sheet.Visible = XlSheetVisibility.xlSheetHidden

// and save it - in blocks if necessar
if (data.Length < BLK_SIZE

Range rng = sheet.get_Range("A1", "A1")
rng.Value2 = data

els

int off = 0
int row = 1
while (off < data.Length

int len = Math.Min(BLK_SIZE, data.Length - off)
string cellData = data.Substring(off, len)

string loc = "A" + row
Range rng = sheet.get_Range(loc, loc)
rng.Value2 = cellData

off += len
row++



--
thanks - dav
david_at_windward_dot_ne
http://www.windwardreports.co

Cubicle Wars - http://www.windwardreports.com/film.htm

Hello Dave,I have tested your example code. The code itself should be OK.
Hello Dave

I have tested your example code. The code itself should be OK. It won't
throw the 0x800A03EC error if we solely run the piece of code. Thus, the
cause of the error depends on when, where and how we execute the code
snippet

I know some scenarios that can result in the error 0x800A03EC based on my
experience. We can start troubleshooting the problem by checking if the
scenarios below meet your situation

1. We cannot change the value of a cell as it enters the calculation mode
Excel is in "Calculation" mode and will not allow the contents of cells to
be changed, otherwise, it will cause a "Calculation Reentrancy" and we may
get the error 800A03EC. An instance of such behavior is, if our automation
add-in exposes a UDF (User Defined Function) that sets the other cells'
values in the UDF definition, the error "800A03EC" will be thrown. E.g. an
UDF defined as this
public object SetValue(Range r, object val)
r.set_Value(XLRangeValueDataType.xlRangeValueDefault, val); // we set
the other cells' values in the UDF definition

I recall you once asked me how to expose UDFs in a COM addin, thus, please
check if the example code is called from a UDF.

There are always problem with calculation reentrancy in excel and you need
to be very careful while implementing something that you are trying to
achieve. One solution I could suggest is to create a combination of COM
Add-in and automation add-in, and register an event that handles WorkSheets
"Calculate" event. The calculate event gets called after every
recalculation of the worksheet. Also create a 2D array that will hold all
the ranges and values that needs to be updated after the calculations are
done. When the UDF (user defined function) =SetValue() gets called and once
the calculation is done, the "Calculate" event gets fired. In the event
handler of "calculate" event the COM Add-in will get the values from the 2D
array and fill the appropriate cells with values. This way you can update
the appropriate cells after calculation.

2. Make sure there is only one thread automating Excel
None of the Office applications, Microsoft Excel included, support
reentrancy. Because the second thread is reentering Excel, and because
Excel is in the processing other tasks, e.g. the menu item click, there can
be problems like 800A03EC. The resolution is to move the code to the main
thread and avoid reentrancy.

3. A known issue of Excel 2003 that can cause the error 800A03EC
http://support.microsoft.com/kb/823988

There can be other reasons for the error 0x800A03EC, if none of the above
fits your situation, please give me more information about where, when and
how the example code is called.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Thank you - we'll check each of these.
Thank you - we'll check each of these. I wish the error codes would tell us
more...

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




:

Hello Dave,The facility error code messge for the error code "0x800A03EC" is
Hello Dave,

The facility error code messge for the error code "0x800A03EC" is "Invalid
flags", which does not tell any useful information.

Please notify me when you finish the check of the hypotheses.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

Jialiang,I am also experiencing this error except on CheckOut.I have a .
Jialiang,

I am also experiencing this error except on CheckOut.

I have a .NET managed add-in for Excel which is throwing the following error
when I make a call to Application.Worksheets.CheckOut("my-url-here"):

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

I'll have to check on the re-entrancy/threading issues, but it's odd that
all of the other API calls which I'm using are working fine (including calls
to CanCheckIn and CheckIn, oddly enough)

I've been struggling with this for some time now. Any additional input
would be much appreciated.

EggHeadCafe - Software Developer Portal of Choice
Factory Pattern - C# .NET Use Refactoring To Handle Versions of Classes
http://www.eggheadcafe.com/tutorial...9c66-d46011818808/factory-pattern--c-net.aspx
 
T

Tom Cook

I spent several days going around in circles with this problem before discovering, by trial and error, that you have to activate the worksheet (sheet.Activate()) before you can change values on it, or select cells on it. Otherwise you get the dread error 0x800A03EC. Hope it helps.



thiele wrote:

error 0x800A03EC - why?
22-Apr-08

When calling the code below we get an Exception "Exception from HRESULT:
0x800A03EC". It cannot be a R/O issue because the user can edit & save the
spreadsheet. It cannut be the language version mis/match because we get an
error much earlier in that case.

Any idea what can cause it? (Note, the methods called in this code do not
call any Excel COM methods so it must be in this code.)

Application excelApp = app.NativeApplication;
Workbook wrkbk = excelApp.ActiveWorkbook;
if (wrkbk == null)
return;

// delete the old Worksheet
Worksheet sheet = FindSheet(wrkbk, "WR_DATA");
if (sheet != null)
{
bool blnAlertStatus = excelApp.DisplayAlerts;
excelApp.DisplayAlerts = false;
sheet.Delete();
excelApp.DisplayAlerts = blnAlertStatus;
}

string data = DocumentDataBuffer.SaveProfileToDoc(app.DocData,
wrkbk.Path == null ? null : wrkbk.FullName);
if (data == null)
return;

// and save it
sheet = (Worksheet) wrkbk.Worksheets.Add(Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
sheet.Name = "WR_DATA";
sheet.Visible = XlSheetVisibility.xlSheetHidden;

// and save it - in blocks if necessary
if (data.Length < BLK_SIZE)
{
Range rng = sheet.get_Range("A1", "A1");
rng.Value2 = data;
}
else
{
int off = 0;
int row = 1;
while (off < data.Length)
{
int len = Math.Min(BLK_SIZE, data.Length - off);
string cellData = data.Substring(off, len);

string loc = "A" + row;
Range rng = sheet.get_Range(loc, loc);
rng.Value2 = cellData;

off += len;
row++;
}
}

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Previous Posts In This Thread:

error 0x800A03EC - why?
When calling the code below we get an Exception "Exception from HRESULT:
0x800A03EC". It cannot be a R/O issue because the user can edit & save the
spreadsheet. It cannut be the language version mis/match because we get an
error much earlier in that case.

Any idea what can cause it? (Note, the methods called in this code do not
call any Excel COM methods so it must be in this code.)

Application excelApp = app.NativeApplication;
Workbook wrkbk = excelApp.ActiveWorkbook;
if (wrkbk == null)
return;

// delete the old Worksheet
Worksheet sheet = FindSheet(wrkbk, "WR_DATA");
if (sheet != null)
{
bool blnAlertStatus = excelApp.DisplayAlerts;
excelApp.DisplayAlerts = false;
sheet.Delete();
excelApp.DisplayAlerts = blnAlertStatus;
}

string data = DocumentDataBuffer.SaveProfileToDoc(app.DocData,
wrkbk.Path == null ? null : wrkbk.FullName);
if (data == null)
return;

// and save it
sheet = (Worksheet) wrkbk.Worksheets.Add(Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
sheet.Name = "WR_DATA";
sheet.Visible = XlSheetVisibility.xlSheetHidden;

// and save it - in blocks if necessary
if (data.Length < BLK_SIZE)
{
Range rng = sheet.get_Range("A1", "A1");
rng.Value2 = data;
}
else
{
int off = 0;
int row = 1;
while (off < data.Length)
{
int len = Math.Min(BLK_SIZE, data.Length - off);
string cellData = data.Substring(off, len);

string loc = "A" + row;
Range rng = sheet.get_Range(loc, loc);
rng.Value2 = cellData;

off += len;
row++;
}
}

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Hello Dave,I have tested your example code. The code itself should be OK.
Hello Dave,

I have tested your example code. The code itself should be OK. It won't
throw the 0x800A03EC error if we solely run the piece of code. Thus, the
cause of the error depends on when, where and how we execute the code
snippet.

I know some scenarios that can result in the error 0x800A03EC based on my
experience. We can start troubleshooting the problem by checking if the
scenarios below meet your situation:

1. We cannot change the value of a cell as it enters the calculation mode.
Excel is in "Calculation" mode and will not allow the contents of cells to
be changed, otherwise, it will cause a "Calculation Reentrancy" and we may
get the error 800A03EC. An instance of such behavior is, if our automation
add-in exposes a UDF (User Defined Function) that sets the other cells'
values in the UDF definition, the error "800A03EC" will be thrown. E.g. an
UDF defined as this:
public object SetValue(Range r, object val) {
r.set_Value(XLRangeValueDataType.xlRangeValueDefault, val); // we set
the other cells' values in the UDF definition.
}
I recall you once asked me how to expose UDFs in a COM addin, thus, please
check if the example code is called from a UDF.

There are always problem with calculation reentrancy in excel and you need
to be very careful while implementing something that you are trying to
achieve. One solution I could suggest is to create a combination of COM
Add-in and automation add-in, and register an event that handles WorkSheets
"Calculate" event. The calculate event gets called after every
recalculation of the worksheet. Also create a 2D array that will hold all
the ranges and values that needs to be updated after the calculations are
done. When the UDF (user defined function) =SetValue() gets called and once
the calculation is done, the "Calculate" event gets fired. In the event
handler of "calculate" event the COM Add-in will get the values from the 2D
array and fill the appropriate cells with values. This way you can update
the appropriate cells after calculation.

2. Make sure there is only one thread automating Excel
None of the Office applications, Microsoft Excel included, support
reentrancy. Because the second thread is reentering Excel, and because
Excel is in the processing other tasks, e.g. the menu item click, there can
be problems like 800A03EC. The resolution is to move the code to the main
thread and avoid reentrancy.

3. A known issue of Excel 2003 that can cause the error 800A03EC
http://support.microsoft.com/kb/823988

There can be other reasons for the error 0x800A03EC, if none of the above
fits your situation, please give me more information about where, when and
how the example code is called.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Thank you - we'll check each of these.
Thank you - we'll check each of these. I wish the error codes would tell us
more...

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




:

Hello Dave,The facility error code messge for the error code "0x800A03EC" is
Hello Dave,

The facility error code messge for the error code "0x800A03EC" is "Invalid
flags", which does not tell any useful information.

Please notify me when you finish the check of the hypotheses.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

Jialiang,I am also experiencing this error except on CheckOut.I have a .
Jialiang,

I am also experiencing this error except on CheckOut.

I have a .NET managed add-in for Excel which is throwing the following error
when I make a call to Application.Worksheets.CheckOut("my-url-here"):

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

I'll have to check on the re-entrancy/threading issues, but it's odd that
all of the other API calls which I'm using are working fine (including calls
to CanCheckIn and CheckIn, oddly enough)

I've been struggling with this for some time now. Any additional input
would be much appreciated.

Did you resolve this issue?
I have the same problem with get_Range in .NET VSTO on machine with non-standard regional settings. Did you find the right solution?


Submitted via EggHeadCafe - Software Developer Portal of Choice
Automating FORM POSTS with Script and IE
http://www.eggheadcafe.com/tutorial...c-aba7916081c3/automating-form-posts-wit.aspx
 
M

Mike Coxeter

Hi,
I ran into a very similar issue to this one and I found a solution. I have posted the details up at http://mcoxeter.wordpress.com/2011/03/25/excel-com-issue-solved/

I hope it helps.

Mike
When calling the code below we get an Exception "Exception from HRESULT:
0x800A03EC". It cannot be a R/O issue because the user can edit & save the
spreadsheet. It cannut be the language version mis/match because we get an
error much earlier in that case.

Any idea what can cause it? (Note, the methods called in this code do not
call any Excel COM methods so it must be in this code.)

Application excelApp = app.NativeApplication;
Workbook wrkbk = excelApp.ActiveWorkbook;
if (wrkbk == null)
return;

// delete the old Worksheet
Worksheet sheet = FindSheet(wrkbk, "WR_DATA");
if (sheet != null)
{
bool blnAlertStatus = excelApp.DisplayAlerts;
excelApp.DisplayAlerts = false;
sheet.Delete();
excelApp.DisplayAlerts = blnAlertStatus;
}

string data = DocumentDataBuffer.SaveProfileToDoc(app.DocData,
wrkbk.Path == null ? null : wrkbk.FullName);
if (data == null)
return;

// and save it
sheet = (Worksheet) wrkbk.Worksheets.Add(Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
sheet.Name = "WR_DATA";
sheet.Visible = XlSheetVisibility.xlSheetHidden;

// and save it - in blocks if necessary
if (data.Length < BLK_SIZE)
{
Range rng = sheet.get_Range("A1", "A1");
rng.Value2 = data;
}
else
{
int off = 0;
int row = 1;
while (off < data.Length)
{
int len = Math.Min(BLK_SIZE, data.Length - off);
string cellData = data.Substring(off, len);

string loc = "A" + row;
Range rng = sheet.get_Range(loc, loc);
rng.Value2 = cellData;

off += len;
row++;
}
}

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
On Wednesday, April 23, 2008 3:11 AM jialg wrote:
Hello Dave,

I have tested your example code. The code itself should be OK. It won't
throw the 0x800A03EC error if we solely run the piece of code. Thus, the
cause of the error depends on when, where and how we execute the code
snippet.

I know some scenarios that can result in the error 0x800A03EC based on my
experience. We can start troubleshooting the problem by checking if the
scenarios below meet your situation:

1. We cannot change the value of a cell as it enters the calculation mode.
Excel is in "Calculation" mode and will not allow the contents of cells to
be changed, otherwise, it will cause a "Calculation Reentrancy" and we may
get the error 800A03EC. An instance of such behavior is, if our automation
add-in exposes a UDF (User Defined Function) that sets the other cells'
values in the UDF definition, the error "800A03EC" will be thrown. E.g. an
UDF defined as this:
public object SetValue(Range r, object val) {
r.set_Value(XLRangeValueDataType.xlRangeValueDefault, val); // we set
the other cells' values in the UDF definition.
}
I recall you once asked me how to expose UDFs in a COM addin, thus, please
check if the example code is called from a UDF.

There are always problem with calculation reentrancy in excel and you need
to be very careful while implementing something that you are trying to
achieve. One solution I could suggest is to create a combination of COM
Add-in and automation add-in, and register an event that handles WorkSheets
"Calculate" event. The calculate event gets called after every
recalculation of the worksheet. Also create a 2D array that will hold all
the ranges and values that needs to be updated after the calculations are
done. When the UDF (user defined function) =SetValue() gets called and once
the calculation is done, the "Calculate" event gets fired. In the event
handler of "calculate" event the COM Add-in will get the values from the 2D
array and fill the appropriate cells with values. This way you can update
the appropriate cells after calculation.

2. Make sure there is only one thread automating Excel
None of the Office applications, Microsoft Excel included, support
reentrancy. Because the second thread is reentering Excel, and because
Excel is in the processing other tasks, e.g. the menu item click, there can
be problems like 800A03EC. The resolution is to move the code to the main
thread and avoid reentrancy.

3. A known issue of Excel 2003 that can cause the error 800A03EC
http://support.microsoft.com/kb/823988

There can be other reasons for the error 0x800A03EC, if none of the above
fits your situation, please give me more information about where, when and
how the example code is called.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
On Wednesday, April 23, 2008 12:36 PM thiele wrote:
Thank you - we'll check each of these. I wish the error codes would tell us
more...

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




"Jialiang Ge [MSFT]" wrote:
 

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