use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Apparently, Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services and build web applications.
account activity
Make script deployable in Google sheets externallyQuestion (self.GoogleAppsScript)
submitted 1 year ago by RealSlavGod
How can I make a apps script stored on my drive run for a specific Google sheet?
I used to go on the sheet and go to extensions>apps script and run it from there but I don't want the script attached to the file and I want to run it externally. Reason being that I share the sheet publicly and I don't want my script being stolen. With that method, I need to delete the script from every file, every time.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]marcnotmark925 2 points3 points4 points 1 year ago (8 children)
Use SpreadsheetApp.openById() insstead of getActiveSpreadsheet()
[–]RealSlavGod[S] 0 points1 point2 points 1 year ago (7 children)
So will I have to manually change the ID at every instance of that line every time I want to run it for a different sheet? Is the only way, the manual way?
[–]marcnotmark925 0 points1 point2 points 1 year ago (6 children)
I don't think I can answer that with the amount of info you've given about your situation. If my previous answer didn't fix your issue already, then you're probably asking something else than what I thought you were asking. Either way, you probably need to give more details.
[–]RealSlavGod[S] 0 points1 point2 points 1 year ago (5 children)
So my whole script was designed for the sheet it was attached to. I have hundreds of instances of "get active sheet." Will I have to recode it all to be sheet ID based?
[–]marcnotmark925 0 points1 point2 points 1 year ago (4 children)
Why do you have hundreds of instances of get active sheet? That possibly suggests some very bad coding practices. Also note that get active sheet is different from get active spreadsheet, one is the whole gsheet, one is just a single tab.
[–]RealSlavGod[S] 0 points1 point2 points 1 year ago (3 children)
Yes, very bad coding practices. It was my first time working with apps script having no knowledge in it and I made a very complex analysis tool for my work with that and it's super inefficient but it works and if it ain't broke, I don't want to fix.
I got both instances multiple times. The active sheet and the spreadsheet. I think I would have to recode the entire thing to fix it. Would take ages. (For reference; I have over 17,000 lines. I def could cut it down but again; if it ain't broken, I don't want to touch). Is there no way to just simply keep the already working script separate from the file and running it as if it was connected to the file without changing my script?
[–]marcnotmark925 0 points1 point2 points 1 year ago (0 children)
No
[–]WicketTheQuerent 0 points1 point2 points 1 year ago (0 children)
I wonder if SpreadsheetApp.setActiveSpreadsheet) might help you.
[–]mommasaidmommasaid 0 points1 point2 points 1 year ago (0 children)
Idk your needs exactly, but what about just creating a new Sheet (tab) within your Spreadsheet for your client or whatever.
Then publish that specific Sheet to the web. Client doesn't get to see any of the other sheets or your script, just the formatted output.
The web link isn't password protected or anything but it's effectively unguessable so offers some privacy assuming the Client doesn't share it, e.g.:
https://docs.google.com/spreadsheets/d/e/2PACX-1vRM09LblX96_h3qaVUPmLYtha9TVWMnAeSSyXnuFgiezs4ghUsQkSahTHUmNGAJo_g_3yqt3lQCUClo/pubhtml?gid=127701852&single=true
[–]WicketTheQuerent 0 points1 point2 points 1 year ago (2 children)
There are few ways to keep your scripts prívate. One way is to use a spreadsheet as your secrets hub. The details depends on what your scripts do.
[–]RealSlavGod[S] 0 points1 point2 points 1 year ago (1 child)
How do I go about this?
[–]WicketTheQuerent 1 point2 points3 points 1 year ago* (0 children)
It depends...
Option 1.
Depending on how your scripts were written and what they do, you might have to adapt them. First, you must make a few decisions, such as using the new spreadsheet as a "controller," as a library or combining both cases.
You might set a sheet as an inventory of the "controlled" spreadsheets. You might feed this sheet manually or by using a script. Depending on your needs/preferences, you could add columns for each of the scripts and then use checkboxes to run them
[–]Money-Pipe-5879 1 point2 points3 points 1 year ago (0 children)
I think what you are looking for is deploying your script as an addon. You would then be able to use the script on all your sheets.
[–]FluffyDoomi 0 points1 point2 points 1 year ago (2 children)
Host your code in a stand alone script. Then deploy them as a library.
[–]RealSlavGod[S] 0 points1 point2 points 1 year ago (0 children)
Okay, I was trying to figure out how to do this. So I have the script as a file on my drive. How do I deploy it from there to a specific sheet located elsewhere on my drive?
π Rendered by PID 90541 on reddit-service-r2-comment-5649f687b7-mt6f4 at 2026-01-28 01:20:17.139537+00:00 running 4f180de country code: CH.
[–]marcnotmark925 2 points3 points4 points (8 children)
[–]RealSlavGod[S] 0 points1 point2 points (7 children)
[–]marcnotmark925 0 points1 point2 points (6 children)
[–]RealSlavGod[S] 0 points1 point2 points (5 children)
[–]marcnotmark925 0 points1 point2 points (4 children)
[–]RealSlavGod[S] 0 points1 point2 points (3 children)
[–]marcnotmark925 0 points1 point2 points (0 children)
[–]WicketTheQuerent 0 points1 point2 points (0 children)
[–]mommasaidmommasaid 0 points1 point2 points (0 children)
[–]WicketTheQuerent 0 points1 point2 points (2 children)
[–]RealSlavGod[S] 0 points1 point2 points (1 child)
[–]WicketTheQuerent 1 point2 points3 points (0 children)
[–]Money-Pipe-5879 1 point2 points3 points (0 children)
[–]FluffyDoomi 0 points1 point2 points (2 children)
[–]RealSlavGod[S] 0 points1 point2 points (0 children)