I am recieving this exception:
System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC.
on this bit of code:
foreach(Excel.Range rng in xlWorkSheet1.UsedRange.Cells)
{
if (rng.Value2 != xlWorkSheet2.get_Range(rng,Type.Missing).Value2) //here
{
...........
I'm basically trying to compare two excel files cell by cell but get_range
seems to be giving me this error. Why?
I think you should be somewhat more specific in getting the range from xlWorkSheet2 by using the address property of rng.
Alternatively you can iterate through the rows and columns of the usedrange and provide the row and column in xlWorkSheet2.Cells[row, column].