View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.dotnet.framework.interop,microsoft.public.dotnet.languages.csharp,microsoft.public.excel.misc
[email protected] IMS.Rushikesh@gmail.com is offline
external usenet poster
 
Posts: 2
Default Excel.Range.Name gives error an exception

Hi All,

I am trying to execute below code but it gives me an COMException

///// Code Start ////
public string GetName(Excel.Range range)
{
try
{
if (range.Name != null)
{
Excel.Name name = range.Name as Name;

if (name.Name != null || name.Name.Length != 0)
{
return name.Name;
}
return string.Empty;
}
return string.Empty;
}
catch(Exception e)
{
return string.Empty;
}
}

///// Code End ////

Now every time my very third line "if (range.Name != null)" gives me
Exception

an exception of type: {System.Runtime.InteropServices.COMException}
occurred

Any suggestions,


thanks & regards,
Rushi