Created
October 26, 2020 02:54
-
-
Save xhiroga/0e24b0e957afd70fdd59482fa62f0bbc to your computer and use it in GitHub Desktop.
[GAS] protect all sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function protectAllSheets() { | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var shs = ss.getSheets(); | |
var me = Session.getEffectiveUser(); | |
for (var i = 0; i < shs.length; i++){ | |
var sheet = shs[i] | |
var protection = sheet.protect().setDescription('protect sheet by "function protectAllSheets()"'); | |
protection.addEditor(me); | |
protection.removeEditors(protection.getEditors()); | |
if (protection.canDomainEdit()) { | |
protection.setDomainEdit(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment