Jun 02 2023 11:49 AM
Jun 02 2023 01:01 PM
Can't reproduce such error, even on protected sheet. If you run on new workbook with such named sheet, do you have an error?
Just in case, slightly modified the script
function main(workbook: ExcelScript.Workbook) {
try {
const stuChassis = workbook
.getWorksheet("STU Chassis")
const stuChassisUsed = stuChassis
.getUsedRange()
stuChassis
.addTable(stuChassisUsed, true)
.setName("STUChassisTable")
}
catch (error) {
console.log("There are already tables present in STU chassis");
console.log(error);
}
return
}
Jun 05 2023 04:51 AM
@Sergei Baklan Yes, even in a new workbook and using your revised code, I get the same error. Could it be a permissions error?
Jun 05 2023 09:40 AM
That's usually workbook/sheet protection, but in that case I have another error
If not protection have no idea what it could be.
Jun 05 2023 11:53 AM
Jun 25 2023 03:44 PM
@BradynHin did you work out a way around it?
My problem comes into play where half my script will work but it will have a "You cannot perform the requested operation." for a setValue operation on a single excel cell but only through power automate. Originally I thought it was something to do with something parsing through with my string variable but it doesn't seem to be that.
Jun 25 2023 05:21 PM
@DanDunne
I figured it out. For some reason workbook.getProtection().unprotect(); wasn't working (to unprotect the whole workbook for editing).
As a workaround I had to put in workbook.getWorksheet("<your sheet here>").getProtection().unprotect(); for each section I wanted to edit. Hopefully this gets addressed by Microsoft at some point in the future. This might also only be a problem for power automate to Officescripts as opposed to inherent to officescripts (which was why it was hard to track down the error).
This was also on an .xlsm file so things may still be okay on the .xlsx if doing a run script from power automate.
Anyway I hope I save people from the headache it caused me!