Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a script into multiple Google Spreadsheets

I am an amateur coder - I really only do a few things to make my life easier. I set up Google Forms and Spreadsheets for tracking discipline problems in different grades at my school. I wrote a short script that notifies the appropriate people by e-mail of any submission and that can filter and create reports about selected learners.

Because I do DIY coding (English and French teacher, so I did not study programming), I often come up with some improvement that should have been obvious from the start. I really do not want to copy and paste the script improvement into every spreadsheet's script editor. I have copied this script as a stand-alone file in Google Drive but I cannot insert it into any of the spreadsheets because the gallery only has access to published scripts/apps. Is there a way around this? I've seen mentions of using libraries, but I have no clue even where to begin. It feels a bit silly that you can create a script as a stand-alone in Google Drive but not actually use it.

Any help would be appreciated.

like image 663
user2091307 Avatar asked Feb 20 '13 13:02

user2091307


People also ask

How do I add multiple scripts in Google Sheets?

You can have multiple scripts in the same script file and you can have multiple script files as well. If you click on the small downward-facing arrow at the right of the Script file name, it will show you options to rename, delete, and create a copy of the script file.

How do I share an app script in Google Sheets?

To share a container-bound project, you simply share the parent container file. For example, if you have a script bound to a Google Sheet, you can make someone an editor of the script by making them an editor of the Google Sheet.


1 Answers

This was initially raised as a problem a while ago, and Google's solution was the "libraries" feature.

So you will want to

  1. You must save a version of your project. File > Manage Versions...
  2. Then go into File > Project Properties and copy the project key.
  3. Then in all other spreadsheets, you must go into the Script Editor and to go Resources > Manage Libraries. Then paste the project key from above and add it to that spreadsheet script.

There is not an automated way to accomplish this. In order to have a script run on any spreadsheet, you must go into the Script Editor for each spreadsheet.

Source

like image 114
Phil Bozak Avatar answered Nov 01 '22 09:11

Phil Bozak