This question already has answers here:
How to allow access for importrange function via apps script?
(5 answers)
Closed 8 months ago.
Using Google scripts, I'm creating a bunch of spreadsheets each of which contains an importrange function. In new google sheets one needs to allow access for that importrange to fetch data from a source file - I was wondering whether it was possible to make it automatic using Google scripts and get round the need to press "allow" manually each time?
It is definitely possible to write an importrange function in Apps Script, but you'll need to run it too, so I don't know if it's going to be any better than clicking "allow".
I guess that, depending on your use-case, you could write a single script in the source sheet that pushes the data to the other sheets and possibly even create them automatically for you. Therefore saving you this click per sheet and possibly some other clicks. We can surely help you here in StackOverflow, but it's mostly working out problems, you'll have to put in some effort to develop it yourself. Take a look at Apps Script page to get started.
I was facing the same issue and I don't think access can be granted through script. It needs to be done manually in each spreadsheet.
Best part is it needs to be done only once in any spreadsheet then it will update automatically.
Related
This question already has answers here:
How to share or distribute google apps script with other users?
(2 answers)
Closed 1 year ago.
I have done my app script for test google sheet.
Now I want to import this app script in another google sheet.
I can copy all code to new app script,
but it seems not a good way and a little stupid.
Is there any better way?
You've got two options
Build a library, this will allow you to easily integrate your code in any spreadsheet
Build an add-on; this is slightly more complex, but will allow your users to use a UI to run your scripts without ever needing to use an editor. In your case it's probably best to use this option if you have a Workspace account, this way you can build a private add-on
I have 50 google sheet files for 50 students. They need to key in their answers in their own google sheet file when they are asked to do so. I have a main google sheet to consolidate their data by using IMPORTRANGE formula. This is my formula:
=QUERY({IMPORTRANGE(...);IMPORTRANGE(...);IMPORTRANGE(...);...},"Select * where Col1 is not null")
I will have 50 IMPORTRANGE in the formula. So as expected, the main google sheet is very lag when the 50 students start to key in their answers at the same time. Sometimes, the formula will show #Value when all the students started to answer the questions at their own google sheet file. I need to keep refreshing the main google sheet so that the data will come out, but it will disappear again in a short while then I need to refresh it again (although it will settle down once most of the students finished answering the questions).
I know that using IMPORTRANGE is really not an efficient way to consolidate their answers in main google sheet file but I don't have other better way.
I tried to write a script so that they can send in their data by clicking the button assigned with the script. However, all the students need to go through the authorization process when they run the script for the first time. They don't know how to proceed when they saw the authorization process (not very good in using computer).
May I know is there any ways or tricks that I can use to solve the IMPORTRANGE issue? Or there are some way to write the script where we are not required to go through the authorization process when we run the script for the first time?
Hope to get some advice and help on this as I couldn't find a better way from Google already. Any help will be greatly appreciated!
If I understood correctly what you are looking is that your spreadsheet show in real-time the data being entered simultaneously on 50 different spreadsheets. I'm afraid that Google Sheets is not the right tool for what you are trying to do the way that you are trying to do it. Basically you have two options : change it or use a different tool.
It's not a good idea to have and array of multiple IMPORTRANGE functions that are being edited simultaneously because while the official docs says that IMPORTRANGE functions are updated every 30 minutes when the source and the spreadsheet having formula are opened at the same time the import is done practically immediately and could happen multiple times during the recalculation making causing it to start over an over again.
Replacing the above array by script might help only if you are open to not have the destination spreadsheet updated on real time as scripts are slow.
Replacing the above array by a program that uses the Google Sheets API also might help only if you are open to not have the destination spreadsheet updated on real time as the spreadsheet refresh.
Regarding running a script without requiring authorization that is only possible when using simple triggers and / or removing all the scopes that require authorization to run. Please bear in mind that you might create installable triggers to run other using the authorization of the user who creates them.
Related
Combining multiple spreadsheets in one using IMPORTRANGE
Why do two users sometimes see different values from importrange?
Multiple IMPORTRANGE
Using that many IMPORTRANGE formulas is definitely a bad idea. What I'd suggest you to do:
keep a list of all your student spreadsheet in your main document
write a script that will browse through all of the spreadsheets from that list and copy/paste values into your main document
create a time based trigger that will run the script every X minutes (or hours), depending on how accurate you want the results to be
This is a simple solution, but efficient. Depending on the amount of data and number of students/spreadsheets you may consider other solutions (like writing a cloud function that will do the same as the script) but I think this will work for your use case
This question already has answers here:
How to protect the Apps Script code in a Google spreadsheet?
(6 answers)
Closed 5 years ago.
I have ID key of the master script and I have did connecting it to another users spreadsheet template as a Library but what I want to do is How to make the spreadsheet template access to the master script being limited or should be not shared.
When I'm going to deleted a master script even the library still appears on the list of clien script of the spreadsheet template but all function seperate dead completely or it has said like this:
YOU DO NOT HAVE ACCESS TO LIBRARY *******, USED BY YOUR SCRIPT, OR IT HAS BEEN DELETED.
Try coment from #user3887038 in Q16075446. It make possible to hide library code, but it made difficult to updating code
Sorry for the dumb question, I have tried to search but did not find an answer. Please point if the answer is already been answered.
I am practicing writing my first google scripts (apps). If I create them from within a sheet they are only available to that sheet (bound). I can create them by creating a new script but I don't know how to make them available to all of my spreadsheets (not just one). THe scripts I downloaded from the store show up but how do I add my scripts.
I do not want to publish these to the world, I just want them available to me so I can access them from any sheet I am working with.
Basic question but I am having trouble understanding the process.
Thanks,
A script bound to a spreadsheet is only available from that sheet, you won't be able to access it from another sheet.
You can also create a script file (not related to any other document) but this will not be available from sheets.
This is how it is meant to be.
One thing you can do to use functions you eventually develop in a script is to make a Library of it, the functions in that library will be available to other scripts if you explicitly link the new script to the library (in the script editor > ressources>library) but this procedure is not as simple as the workflow you imagine in your question : each document will have to contain a minimal piece of code that will call the script library functions.
The last option to get create a "spreadsheet-with-script" and to simply make copies of this original spreadsheet (that has a script) and that copies will have the script copied as well.
This question already has answers here:
How to protect the Apps Script code in a Google spreadsheet?
(6 answers)
Closed 6 years ago.
Is there a way to keep your GAS code a secret? I'm needing to keep some code in a spreadsheet secret.
Thanks in advance.
Maybe you can make your script separate from the spreadsheet. Then import it as a library. I believe that keeps your code private.
Just as a note, it seems that anyone with edit access to a spreadsheet also has edit access to the script associated with the spreadsheet.
You can do this via a share, but it is not easy. Share the document with another account, the other account is then able to access the spreadsheet. You can trigger the script in the other account via a URL. I have done this before, it does work.