I've created a script with the new Office Scripts in Excel on the web. The script simply sets the fill color for a range in the current worksheet, gets the used range, and then tries to write the range's address to the console.
async function main(context: Excel.RequestContext) {
let workbook = context.workbook;
let worksheets = workbook.worksheets;
let selectedSheet = worksheets.getActiveWorksheet();
selectedSheet.getRange("B3:E6").format.fill.color = "E2EFDA";
// write used range to console
let usedRange = selectedSheet.getUsedRange();
usedRange.load("address");
context.sync();
console.log("used range = " + usedRange.address);
}
Running this script generates the following error message:
The property 'address' 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.
Seems like I'm already doing as the error message guidance suggests -- i.e., calling the load
method to load the address
property and then calling context.sync()
after the load. What am I missing here?