Open ChemMitch opened 10 months ago
Hi @ChemMitch,
Yes, that is the expected behavior. There's a comment to that effect in the [Range.find sample(https://learn.microsoft.com/en-us/javascript/api/excel/excel.range?view=excel-js-preview#excel-excel-range-find-member(1)). To avoid an error being thrown, you can instead use the Range.findOrNullObject method. That returns an object with isNullObject
property to check. More information about the *OrNullObject pattern can be found here.
The base description of Range.find should specific the error throwing. I'll leave this issue open until that's resolved. @alison-mk. could you please follow up with that?
Thank you once again, Alex!
A follow-up question. Given this code
export async function getVocabularySheet(workbook: Excel.Workbook): Promise
this error occurs:
The property 'isNullObject' is not available. Before reading the property's value, call the load method on the containing object and call "context.sync()" on the associated request context.
But I'm doing what they say! I've tried calling vocabSheet.load("isNullObject"); and the same error occurs (plus a warning about performance.
So, what's the correct way to access isNullObject?
Hi @ChemMitch,
That should be working. I put your code into Script Lab and it seems to be working fine. Here's the gist.
@ChemMitch You need to load
isNullObject'
First ten you can use it.
for example
vocabSheet.load(['isNullObject']);
await context.sync();
//now you can use isNullObject
if (vocabSheet.isNullObject) {}
Thanks, @junaid042 . I did that but got the error anyhow. I've seen that happen a lot.
You never need to load isNullObject
. That property should always load even if you don't explicitly load it with the load()
method.
Please import Alex's gist into Script Lab and see if it works for you.
I can run Alex's gist in script lab fine.
The case I'm trying to run within Excel now is a little different.
Is isNullObject supported on a Range?
I get errors consistently invoking it.
The code in your earlier comment shows that you are calling isNullObject on a Worksheet object, not a Range object.
Hello MIcrosoft Team,
I'm using the find method to look for text and seeing a RichApi.Error with code ItemNotFound.
Is that the expected behavior when the specified text is not found?
Thanks in advance!
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.