Sub topic 2
Controlling what editors and viewers can do
This chapter assumes you can share a Google Sheet with people, assign roles (Viewer, Commenter, Editor), and open the Share dialog. It also assumes you own the sheet or have permission to change its sharing.
Limit what editors can do
Editors can change permissions and share the file with others by default. To stop this:
- Open the Share dialog.
- Click the settings (gear) icon.
- Turn off Editors can change permissions and share.
Only the owner can now add or remove people.
Limit what viewers and commenters can do
In the same settings panel, turn off Viewers and commenters can see the option to download, print, and copy. This hides those options in the interface.
> Hiding the options does not stop a determined viewer from reading or copying the data. Use it to reduce casual copying, not as a security control.
Protecting sheets and ranges
Protection limits who can edit a sheet or a range, even when others have Editor access.
- Select Data > Protect sheets and ranges.
- Choose a sheet or range, then click Set permissions.
- Select Only you or Custom and add the people allowed to edit.
To do this with Apps Script, bind a script to the spreadsheet and run:
function protectActiveSheet() {
const sheet = SpreadsheetApp.getActiveSheet();
const protection = sheet.protect().setDescription('Totals - owner only');
const me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}Reviewing and revoking access
- Open the Share dialog to see everyone with access and their roles.
- Change a role with its dropdown, or choose Remove to revoke access.
- Check General access. Set it to Restricted if the link should no longer open the file.
The owner cannot be removed. Transfer ownership first if you need to remove the current owner.
Exercise
An editor should be able to edit most of a sheet but not the Totals range. Which feature do you use, and what do you set?
Show answer
Use a protected range on the Totals range (Data > Protect sheets and ranges), then set permissions to Custom or Only you so that only the intended people can edit it.