Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel error HRESULT: 0x800A03EC while trying to get range with cell's name

Tags:

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. 
like image 476
Teerasej Avatar asked May 21 '09 04:05

Teerasej


People also ask

How do I fix exceptions from Hresult 0x800ac472?

To fix it, try close the excel from Task Manager once and re-run the BoT. It should work.


1 Answers

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.

like image 116
Dominic Zukiewicz Avatar answered Oct 09 '22 20:10

Dominic Zukiewicz