I am in the process of removing protection from my spreadsheet so that I can eliminate autofilter and delete certain rows. My ultimate goal is to create a table in power automate, allowing me to import it into Power Apps.
How do I go about unprotecting my sheet?
The code snippet below is not working as expected, likely because it does not include the necessary password. How can I modify it to accept a password?
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
selectedSheet.getProtection().unprotect();
// Turn off autofilter on selectedSheet
selectedSheet.getAutoFilter().remove();
// Delete rows 1 through 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.
It seems like the issue may be related to the absence of the password in the script. I have the password but unsure where to input it.
I reviewed this example but could not find a place to enter the password.
Protect Worksheet in Office Scripts with Options
Updated error:
https://i.sstatic.net/4Dg6f.png
https://i.sstatic.net/3vY9R.png
Error message:
{ "message": "We were unable to run the script. Please try again.\nWorkbook not found.\r\nclientRequestId: b29bf86c-8a12-4ab3-b639-2350a0022b89", "logs": [] }
Any assistance would be greatly appreciated.