
Note that scripts must explicitly call this method to associate a protected range with a The named range must be on the same sheet as the current protected If the named range covers aĭifferent area from the current protected range, this method moves the protection to cover the Protection - the object representing the protection settings, for chaining AuthorizationĪssociates the protected range with an existing named range. Neither the owner of the spreadsheet nor the current user can be removed.Īn array of email addresses of the users to remove. Users in the domain have edit permission, those users are still be able to edit the protectedĪrea. Note that if any of the users are members of a Google Group that has edit permission, or if all String - the name of the protected named range, or null if the protected range is notĪssociated with a named range Authorization Logger.log(protection.getRangeName()) // Verify the name of the protected range. tRangeName('Test') // Associate the protection with the named range. Ss.setNamedRange('Test', range) // Create a named range. Protect a named range in a spreadsheet and log the name of the protected range. However, creating a protected range from a named range in the Google Sheets UI associates Named range, without calling setRangeName(rangeName), is not sufficient to associate Range.protect() to create a protection from a Range that happens to be a Note that scripts must explicitlyĬall setRangeName(rangeName) to associate a protected range with a named range calling Returns null if the protection is not associated with a named range. Gets the name of the protected range if it is associated with a named range. Scripts that use this method require authorization with one or more of the following scopes: User - an array of users with permission to edit the protected range or sheet Authorization

Protect the active sheet, then remove all other users from the list of editors. Not have permission to edit the protected range or sheet. Gets the list of editors for the protected range or sheet. Sets whether or not this protected range is using "warning based" protection. Unprotects the given array of ranges within a protected sheet. Sets whether all users in the domain that owns the spreadsheet have permission to edit theĪssociates the protected range with an existing named range.Īdjusts the range that is being protected. Sets the description of the protected range or sheet. Removes the specified target audience as an editor of the protected range. Removes the given array of users from the list of editors for the protected sheet or range. Removes the given user from the list of editors for the protected sheet or range. Gets an array of unprotected ranges within a protected sheet.ĭetermines if the protected area is using "warning based" protection. Returns the IDs of the target audiences that can edit the protected range. Gets the type of the protected area, either RANGE or SHEET. Gets the description of the protected range or sheet. Var protection = sheet.protect().setDescription('Sample protected sheet') Īdds the given user to the list of editors for the protected sheet or range.Īdds the given array of users to the list of editors for the protected sheet or range.Īdds the specified target audience as an editor of the protected range.ĭetermines whether all users in the domain that owns the spreadsheet have permission to editĭetermines whether the user has permission to edit the protected range or sheet. Var sheet = SpreadsheetApp.getActiveSheet() Var protections = ss.getProtections() įor (var i = 0 i < protections.length i++) // Protect the active sheet, then remove all other users from the list of editors. } // Remove all range protections in the spreadsheet that the user has permission to edit. Protection.removeEditors(protection.getEditors()) permission comes from a group, the script throws an exception upon removing the group.

Ensure the current user is an editor before removing others. Var protection = range.protect().setDescription('Sample protected range') Protect range A1:B10, then remove all other users from the list of editors. Spreadsheets created with the older version of Google Sheets, use the PageProtection A protected sheet may include unprotected regions. A protected range can protect either a static Access and modify protected ranges and sheets.
