I am currently working on Excel Addin Application using C# and Excel Interop. I am looping through a range of cells. I am trying to check if a cell is Named or not.
But when I am trying to add a if condition there is exception thrown if the range is not named. The exception is
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
This is kind of wierd.
if(r.Name == null)
{
item.name="Not named";
} else
{
item.name = r.Name.Name;
}
The exception is thrown at if condition itself, why does the Range object does not return null if it is not named ?
Is there a way to check if the range has a Name or not. I do not seem to find any other solution.
Any help in this regards is appreciated.
Thanks