I am trying to run a simple script I have recorded on Excel which I want to run as a step in power automate.
When I try and run the script I get this error message in power automate
We were unable to run the script. Please try again.
WorksheetCollection.getActiveWorksheet() is not allowed when run via Power Automate. Please modify your script to specify a target worksheet.
The script it copied below - I suspect this is something very easy - but have limited experience of scripts / VBA other than using the record function and cant find the solution anywhere - so any help would be most appreciated.
Many thanks
Matt
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
// Replace Stongly Agree with 5 on sheet student data
selectedSheet.replaceAll("Stongly Agree", "5", {
completeMatch: false,
matchCase: false
});