tags:

views:

21

answers:

0

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;