Share via

Excel pause sheet protection in script without pop-up prompt.

Anonymous
2024-09-20T15:54:01+00:00

Appreciate any help on this. I am working with Excel app online. I have made a script to clear contents (and make other adjustments) to certain cells. The sheet is protected with the selected cells as unprotected. The script works fine when the sheet is unprotected, but has error when the sheet is protected. To accommodate this, I have tried to enter code to unprotect/pause protection when the script is run. I managed to get that to work, however, each time a pop-up window appears asking for the password. I want to find a way to have the password in the script itself and not do the pop-up prompt. Here is a slimmed down version of my script :

function main(workbook: ExcelScript.Workbook, password: string) {

let selectedSheet = workbook.getActiveWorksheet(); 

password="12345"; 

protection.pauseProtection(password); 

// selectedSheet.Unprotect("12345"); 

selectedSheet.getRange("D3:E3").clear(ExcelScript.ClearApplyTo.contents); 

// selectedSheet.Protect("12345"); 

protection.resumeProtection(password); 

}

Microsoft 365 and Office | Excel | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-09-20T18:38:20+00:00

    Please delete this post. I found a different solution. Thanks.

    Was this answer helpful?

    0 comments No comments