Excel error HRESULT: 0x800A03EC while trying to get range with cell's name
Solution 1
The error code 0x800A03EC
(or -2146827284) means NAME_NOT_FOUND; in other words, you've asked for something, and Excel can't find it.
This is a generic code, which can apply to lots of things it can't find e.g. using properties which aren't valid at that time like PivotItem.SourceNameStandard
throws this when a PivotItem doesn't have a filter applied. Worksheets["BLAHBLAH"]
throws this, when the sheet doesn't exist etc. In general, you are asking for something with a specific name and it doesn't exist. As for why, that will taking some digging on your part.
Check your sheet definitely does have the Range you are asking for, or that the .CellName
is definitely giving back the name of the range you are asking for.
Solution 2
I ran into this error because I was attempting to write a string to a cell which started with an "=".
The solution was to put an "'" (apostrophe) before the equals sign, which is a way to tell excel that you're not, in fact, trying to write a formula, and just want to print the equals sign.
Solution 3
The meaning of the completely undocumented error 800A03EC (shame on Microsoft!) is something like "OPERATION NOT SUPPORTED".
It may happen
- when you open a document that has a content created by a newer Excel version, which your current Excel version does not understand.
- when you save a document to the same path where you have loaded it from (file is already open and locked)
But mostly you will see this error due to severe bugs in Excel.
- For example Microsoft.Office.Interop.Excel.Picture has a property "Enabled". When you call it you should receive a bool value. But instead you get an error 800A03EC. This is a bug.
- And there is a very fat bug in Exel 2013 and 2016: When you automate an Excel process and set
Application.Visible=true
andApplication.WindowState = XlWindowState.xlMinimized
then you will get hundreds of 800A03EC errors from different functions (like Range.Merge(), CheckBox.Text, Shape.TopLeftCell, Shape.Locked and many more). This bug does not exist in Excel 2007 and 2010.
Solution 4
I got the error with a space in a Sheet Name:
using (var range = _excelApp.Range["Sheet Name Had Space!$A$1"].WithComCleanup())
I fixed it by putting single quotes around Sheet Names with spaces:
using (var range = _excelApp.Range["'Sheet Name Had Space'!$A$1"].WithComCleanup())
Solution 5
I had this problem when I was trying to use the range.AddComment() function. I was able to solve this by calling range.ClearComment() before adding the comment.
Related videos on Youtube
Teerasej
Updated on July 09, 2022Comments
-
Teerasej almost 2 years
I am working with Window Service project. that have to write data to a sheet in Excel file in a sequence times.
But sometimes, just sometimes, the service throw out the exception "Exception from HRESULT: 0x800A03EC" while it's trying to get range with cell's name.
I have put the code of opening excel sheet, and getting cell here.
- OS: window server 2003 Office:
- Microsoft Office 2003 sp2
1: Opening excel sheet
m_WorkBook = m_WorkBooks.Open(this.FilePath, 0, false, 5, "", "", true, Excels.XlPlatform.xlWindows, ";", true, false, 0, true, 0, 0);
2: Getting cell to write
protected object m_MissingValue = System.Reflection.Missing.Value; Range range = m_WorkSheet.get_Range(cell.CellName, m_MissingValue); // error from this method, and cell name is string.
-
Fabrice T almost 8 yearsI have the same problem In C# code I typed
xApp.Cells(3, 1).FormulaR1C1 = "=SUM(R[-2]C:R[-1]C)"
: fails; thenxApp.Cells(3, 1).FormulaR1C1 = "=(R[-2]C+R[-1]C)"
: fails; and thenxApp.Cells(3, 1).FormulaR1C1 = "=A1+A2"
success
-
ForeverWintr about 11 yearscan you provide a reference to corroborate your statement that "The error code 0x800A03EC (or -2146827284) means NAME_NOT_FOUND"? I haven't been able to find one...
-
Dominic Zukiewicz about 11 years@ForeverWintr: I'm trying to dig up a link, but this reply was from 10 months ago and based on my research at the time. I have also been building Excel based VSTO solution for a while and have seen this quite a lot when it cannot locate an item by name, by range etc. Its a very generic error, so it can come up in other Office applications and mean something different (like file saves, automation errors), but if it doesn't work for this OP, its helped me resolve similar issues in the past.
-
ForeverWintr about 11 yearsThe reason I ask is that I've been encountering 0x800A03EC with such frequency and from such a diverse range of calls in my VSTO project that I'm beginning to think it just means "Excel error." Your answer is the only reference to "NAME_NOT_FOUND" that I've come across.
-
Jeremy Thompson almost 11 years@ForeverWintr you use the Err.exe tool, its a command line tool, simply put it in System32 and call it from a dos prompt:
err 0x800A03EC
, it uses OS Header File's. -
DustWolf about 5 yearsCan also happen if you are writing to a cell with a coordinate of zero. Cells are numbered 1 and up.
-
Maxter over 4 yearsBut what if I do want to write a formula?