r/GoogleAppsScript • u/PHoenixNoMore • Oct 16 '26
Question Share Google Sheet, allow Script running, but block editing the Script?
I've created a Google Sheet for an RPG character sheet. I wrote a script to make it work. Now I wish to share it online, but am worried that anyone accessing the Sheet can also edit the script. I want the people I share the sheet with to be able to run the scripts, but not be able to change them. The last thing I want is for somebody to turn it into a virus or something. My online searches have provided zero instructions on protecting the scripts from editing, but still allowing usage. Is what I want even possible? If so, could they point me to any videos that show how? Thanks.
3
u/DrMorris Oct 16 '26
Believe the only way to achieve something like this is to publish it as an add on.
2
u/cdchiu Oct 16 '26
You can publish it as a web site and they don't get direct access to the sheet.
2
u/carbonizedtitanium Oct 17 '26
do you need people to edit your copy of the sheet? why not share as "view-only" and you let whoever wants to use it to just make a copy of it?
1
u/mommasaidmommasaid Oct 16 '26 edited Oct 16 '26
Is this for multiple users editing the same spreadsheet?
If so and if you are able to trigger your script through e.g. edits, then it is easy to set up a standalone script that only you have access to. That script is then triggered when the shared spreadsheet is edited.
The standalone script runs as "you", with authorizations you provide, so your users don't have to authorize anything.
You might need to convert some buttons to checkboxes, or traditional menu items to dropdowns.
1
u/WicketTheQuerent Oct 17 '26
It depends on how the users run the script functions. If they are run through triggers, you can programmatically create the triggers from another project; but if you run the scripts from a custom menu, sidebar or dialog, you need to create an add-on.
This is because spreadsheet editors can also edit the bound Apps Script project; there is no way to prevent them from editing it.
1
u/_Kaimbe Oct 21 '26
A library could work, depending on your needs. https://developers.google.com/apps-script/guides/libraries
But you should have people make their own copy of the sheet anyway, so it won't matter if they change their copy.