I am trying to unprotect my sheet so I can remove autofilter and delete some rows. My plan from there is to create a table in power automate so i can read it into Power Apps.
How can I unprotect my sheet?
I am running the below, I assume it isnt working due to not having the password in the code. How can I format this to accept a password?
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
selectedSheet.getProtection().unprotect();
// Toggle auto filter on selectedSheet
selectedSheet.getAutoFilter().remove();
// Delete range 1:6 on selectedSheet
selectedSheet.getRange("1:6").delete(ExcelScript.DeleteShiftDirection.up);
}
Error: Line 4: WorksheetProtection unprotect: The argument is invalid or missing or has an incorrect format.
Again, I am assuming this is due to me not having the password in the script. I have the password but not sure where to input it.
I look at this example but no where to enter password .
Protect Worksheet in Office Scripts with Options
Updated error:
error msg { "message": "We were unable to run the script. Please try again.\nWorkbook not found.\r\nclientRequestId: b29bf86c-8a12-4ab3-b639-2350a0022b89", "logs": [] }
any help would be appreciated.