In this tutorial, we will go over the basics of adding users as Editors to Google Sheets with Google Apps Script. We’ll go through the process step-by-step, starting with two very basic codes and then progress on to error handling so your code doesn’t break for your user.
In Google Sheets just like Docs, Slides, Forms and Sites you can add co-editors to work on your projects. This is usually done straight from Google Drive or within the chosen Google file in the top right with the Share button.
The rules for sharing a specific user as an editor are pretty simple. The user must have either a Gmail (email@example.com) account, GSuite for Education domain account (firstname.lastname@example.org) or Google Workspace (formerly, Gsuite) account with an email in the workspace’s domain (email@example.com).
Now that we have all the basics, let’s go ahead and write some Google Apps Script code. First of all, open a Google Sheet. It can be one that you want to use to add and remove editors with code on a project you are working on or just a practice Google Sheet. Then go to Extensions > App Script.