Forum Discussion
"You cannot perform the requested operation.", code: "AccessDenied", method: "addTable", line: 9}
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.
- DanDunneJun 26, 2023Copper Contributor
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!