Range names that do not refer to a range throw an error when range refers to a

Posted by: dean.kinnear on 28 March 2023, 9:09 am EST

  • Posted 28 March 2023, 9:09 am EST

    if I have a workbook with a name “test” and the range name refers to a value instead of a range,

    var expr = name.getExpression();

    var parentSheet = expr.source.getSheet()

    expr.source.getSheet() throws an error because the name does not refer to a range.

    How can I tell ahead of time that a name does not refer to a range?

    Thanks!

    Dean

  • Posted 29 March 2023, 7:28 am EST

    Hello,

    After investigating the code snippet provided by you, it seems that you are trying to get the sheet instance using getSheet() method on the “source” property of the Expression type object.

    Please note that when you use getExpression() method of the NameInfo object, it returns an object of GC.Spread.CalcEngine.Expression type. The Expression type object does not have “source” property and that is why it throws an error when you try to get the sheet instance.

    Please describe your use case so that we can provide you assistance accordingly.

    regards,

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels