google-apps-scriptgoogle-sheets

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:


Solution

  • 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, in order to create a library. Then, import this library into the other spreadsheets. 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 spreadsheet using it.

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

    function doSomething(){
       myLibrary.doSomething();
    }