开发者

How do I check if a name is in use in Excel using VSTO?

开发者 https://www.devze.com 2022-12-21 03:25 出处:网络
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 b

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消