Google Spreadsheet Scripts shared across spreadsheets (not libraries)

前端 未结 1 372
南笙
南笙 2020-12-09 12:56

I have done a ton of searching for this problem and I think the issue is all the answers result in a solution that requires you to create a library. Then, the only way I se

相关标签:
1条回答
  • 2020-12-09 13:18

    Maybe what what you're asking for is just a way to copy exactly what's in a master script over to all of your scripts that are inside the spreadsheet copies so that it replaces their code and skips over the need to reference a library, but I'll offer my impression on how the library setup works...

    the only way I see to add that library to a spreadsheet is to create a new script for that spreadsheet

    When you make a copy of a spreadsheet that already has a script with a library reference, it'll stay in with the new copy. So, you shouldn't have to create any new scripts after you've created one spreadsheet template to copy.

    That one spreadsheet template should have a library reference to the master script. The master doesn't need to be inside a sheet and you shouldn't be copying the original / master script.

    So, we have: 1 master script, 1 spreadsheet template that has a script that references the master, then as many copies of the template as you want.

    Now when you setup the library reference, you have the option to connect it in the spreadsheet template in dev mode. This will allow any changes to existing functions in the master script to instantly affect the template copies (unless authorization is first needed). If you have it this way, you will might want to test out your changes in a copy of the master script first. The other option is to keep dev mode turned off and have users of the template copies manually update their library version inside each of their scripts (unless there's an automatic version updating system I don't know about).

    This setup still doesn't solve the issue of adding a completely new function to the master script that each template copy needs to reference though. Maybe some one can comment or provide a separate answer to that.

    [Update: 3/15/2015] So publishing an Add-on to the Chrome Web store lets you install an Add-on once and have it appear in all your Sheets / Docs / Forms which I believe was what was originally needed for OP. Pushing new versions out updates all Google docs that use it.

    https://developers.google.com/apps-script/add-ons/

    0 讨论(0)
提交回复
热议问题