How do I check if a name is in use in Excel using VSTO?
I need to know if a name is already in use in Excel (for example as a named range) so that I do not 开发者_运维百科allow the attempted creation of duplicate names. I tried the following but the loop body never executes (there are no exceptions thrown, it just looks like the collection is empty).
Can anyone suggest and alternative?
foreach (Excel.Name n in _workbook.Names)
{
if (n.Name == name) return true;
}
return false;
精彩评论