Here's my script, but I can't get it to work for some weird reason??!!! Driving me nuts.
function removeThenSetProtection() {
// Remove all range protections in the spreadsheet that the user has
//permission to edit.
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);
for (var i = 0; i < protections.length; i++) {
var protection = protections[i];
if (protection.canEdit()) {
protection.remove();
}
}
}
Change:
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);
To:
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);
That way, you'll be assured that you are getting a reference to everything that is protected, and future conflicts don't happen.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다