3
votes

Excel supports the concept of a PERSONAL.XLS file which contains my personal scripts, which I want to be able to use on any spreadsheet/workbook that I open.

How do I do similar in Google Docs, i.e. have a set of scripts which, regardless of which Google Spreadsheet I open, will cause the onOpen event to be run and will thus add my extra menu?

3
You would probably have to write a script that invokes this every time it sees a new spreadsheet in your docs list.Phil Bozak
Possible duplicate of Use script in all spreadsheetsRubén
@Rubén, surely the referenced question is a duplicate of this one, not the other way round, because this question was asked over a year before the other one!Captain Payalytic
@CaptainPayalytic It doesn't matter which question is older, what makes it important are the answers. You didn't accept an answer yet. What do you think about the current answers to this question?Rubén

3 Answers

2
votes

You cannot do that in Google Spreadsheets. However the best practice is to

  1. Write a standalone script with your onOpen and other functions.
  2. Publish this as a library
  3. Write a shell onOpen in each of the spreadsheets that you create manually. :( This shell function will call the library's onOpen.

However, if you create a copy of a spreadsheet that has an associated script, then the copy will also have the script in it.

1
votes

1) You can open your Script and from the Publish menu select "Test as add-on".

2) Now under "Configure New Test" you can select a document and then run the add-on for that doc.

Unfortunately you have to do this for each document one at a time. I would really love it if there was a way to tell a script to be available for all my spreadsheets, or at least have an easy way to install a personal add-on on a per-sheet basis just like you can install an add-on from the marketplace, kinda like a personal marketplace.

0
votes

Although not recommended, You can also copy set of scripts to all other google spreadsheets programmatically using AppsScriptApi