2
votes

I have a Google Sheets script that's bound to a specific doc. Basically it takes the results of certain cells, then it used these values in doc.

I have multiple Sheets I'd like to "attach" to this script. All the other Sheets have the exact same tabs and cell names, etc.

Is there a way to turn that bound script to a standalone script, then attach them to the other Sheets?

1
You'll always have to define what sheet you're working in. Either take the active sheet (var ss = SpreadsheetApp.getActive()) or define a specific sheet (var ss = SpreadsheetApp.openById("abc1234567");). If this is not what you're looking for, consider to clarify your question. - Casper
You can use either a library or an add-on to accomplish what you want to do. In either case, there needs to be some set up or installation, unless you are in a domain and can deploy the add-on to all users in the domain. - Alan Wells
You can use library or an add-on as Sandy Good said. But if you are required to create the project into a Spreadsheet as a bound script, how about using Google Apps Script API? 1. Retrieve the project from the existing Spreadsheet using projects.get. 2. Create the retrieved project into other Spreadsheet as a bound script using projects.create. - Tanaike

1 Answers

4
votes

You cannot unbind a bound script:

The file a bound script is attached to is referred to as a "container". Bound scripts generally behave like standalone scripts except that they do not appear in Google Drive, they cannot be detached from the file they are bound to, and they gain a few special privileges over the parent file.

To use the functionality you've created, you'll want to export the bound script as a library and import it in the other spreadsheets' script editors. You may also have to do some tweaks to get any UI alterations

Note that an installed library will not automatically update the used version, so if you make changes to your library source and save a new version, you'll have to go through all the spreadsheets that reference it and update the library version.


The alternative to a library is to go through the process to publish your script as an add-on. This will let you redeploy your changes without needing to go through every single spreadsheet.