Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have one script for multiple spreadsheets?

I have one master spreadsheet and a number of copies. This master spreadsheet uses some scripting.

Is it possible to link all the copies of this master spreadsheet to the same script as in the master spreadsheet?

Objective:

  • changes in the scripting in the master spreadsheet are automatically used by the copies
  • aka: low maintenance
like image 366
Stefan van Aalst Avatar asked May 08 '12 14:05

Stefan van Aalst


People also ask

Can you have 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.


2 Answers

amleczko is right: you should use the new library feature in Google Apps script.

However, as of today, you won't be able to do exactly what you want (using the same script for several spreadsheets). What you can do instead is save a version of your script (Files > Manage Versions...), in order to create a library. Then, import this library in the other spreadsheets (Resources > Manage Libraries...). Switch on the "development mode" so every change made do the library will immediately take affect in the spreadsheets using this library. Otherwise, you will have to save a new version of the library for every change, and manually update the version number of the library in every spreadsheets using it.

The problem is, you need to write a script in every spreadsheets using your library, with skeleton functions like this:

function doSomething(){
   myLibrary.doSomething();
} 
like image 94
antoine Avatar answered Oct 10 '22 05:10

antoine


best way is to publish as add-on, then install the add-on, it will appears in every spreadsheet you open. and you can publish as private, which only seen by yourself.

like image 42
gogi Avatar answered Oct 10 '22 06:10

gogi