Is it possible to create a script in Google Drive that you can call or execute on any opened spreadsheets without having to keep installing the script on each opened spreadsheet?
I have data I upload to Google drive from time to time and these data comes from suppliers. I upload them to GDrive and then I do all sorts of stuffs like moving columns or adding new columns etc. I want to create a script to automate this but the problem is the script I'm creating will be attached to that spreadsheet I'm using and any new uploaded spreadsheet means I have to copy the script over to that new spreadsheet so I can run it there again.
This is kinda hard to explain but is it possible to create a script, save it on GDrive and whenever I am viewing a new spreadsheet I can run that script to do things to that spreadsheet I'm currently viewing?
Related
I am very new to Google Apps Script. I created a Macro in Excel with VBA. My process is downloading a CSV that I save to my hard drive, opening it (my PERSONAL workbook is open at all times) and then running my macro which will format the list/perform the steps of my macro. I would then save and manually upload that list back to Google Drive.
This is obviously inefficient and The rest of my team uses Google Drive/ Google Sheets and so I am attempting to teach myself how to build out the same macro in Google Apps Script. I understand the difference between bound and unbound scripts - this is similar to Excel in the sense that if I wanted to run my macro on multiple sheets, I would have to save it to my PERSONAL spreadsheet where I stored all of my macros and then have that sheet open at the same time that I ran the macro on a different spreadsheet.
However, for Google Apps Script, it appears as though you simply cannot run a macro through multiple different workbooks without manually copying and pasting your code to every new spreadsheet. Is this true? I see that it could be added in the app store and published as an add-on but my script is painfully basic, I'm just changing some words and formatting. It seems odd that this cannot be applied to multiple spreadsheets the way that it can in Excel. My goal was to use something like:
function onOpen(e) {
SpreadsheetApp.getUi() // Or DocumentApp, SlidesApp, or FormApp.
.createMenu('List Upload')
.addItem('Format List Upload', 'formatListUpload')
.addToUi();
where formatListUpload would run my formatting script so that my coworkers could just click "Format List Upload" as a menu option and the new spreadsheet they had just opened would be quickly formatted. This seems like base-level functionality for macros/ app script. Is there truly no way that this can be done?
Many, many thanks!
From the question
However, for Google Apps Script, it appears as though you simply cannot run a macro through multiple different workbooks without manually copying and pasting your code to every new spreadsheet. Is this true?
No
Is there truly no way that this can be done?
Instead of using a simple trigger you might use an installable trigger, but this option is limited to create 20 triggers by script / user. To make this work you will need somehow to open the spreadsheet i.e. SpreadsheetApp.openById(spreadsheetId)
Options to avoid having to create an add-on
One option that doesn't requires installable triggers is to submit the spreadsheet having the macro to the templates gallery and use the template to create the new spreadsheets
Another option is use script to create a new spreadsheet and the installable trigger for it.
One more option is to create a new spreadsheet, grab the spreadsheet id, either manually or programmatically, then use it to create the installable trigger for the new spreadsheet.
My plan is to link a google app script to my google sheets. I have 16 tabs on my google sheets. I want to make 16 app script files inside the same app script project. I also want to set time trigger on each app script to run at a certain time. My question is will every file inside the app script file will run, or only one app script will run?
The output I am looking for is that I do not have to press any button on the sheets or the app script. I want it to run each app script file at a certain time, and for the google sheets to update at that time. Each google sheet tab should update at the time they are assigned in the app script. How can I make this happen?
Thanks in advance.
Every scripts are runnable, unless the function names do not duplicate.
A project is similar to a html file, while each script file is included by <script src="name.js">
However, I doubt whether you really need one script file, or even a function for each sheet.
Of course, it depends on what you want to do. But I guess the works are similar and they could be combined into one or a few functions.
I have programmed a script in a Google Sheet to treat the data stored in this script. This script runs automatically based on time.
I use a Google Sheet per month, so I make a copy of this Sheet with its programmed script every month. I modify the date and rename the file.
Nervertheless when I make the copy, it's necessary to get permissions in Google Apps Script to run the script. I would like to program a script that makes the copy, rename the file, changes the date and gets permission automatically. Making copy, renaming and changing date are easy, but I don't know how get permission automatically. Is it possible? Anyone can help me?
I have a font and alignment script which works like a charm on our daily spreadsheet. However I copy the blank file (template) 30 ish times for each month. As soon as I have done this, the font script stops working unless I go in and authorise it for each new sheet. Is there any way, maybe with the script library i can run it automatically and not have to authorise each new sheet? All users have edit access to the sheet. I have been reading and playing with the script library but can't seem to get it to work at all.
Thank you for any help.
The simplest way to authorize a script and then not need to reauthorize a derivative of it, is to not create a derivative of it. Currently, you indicate the workflow is create a copy of yesterday's document, and then everyone works on the copy.
If you reverse the order, such that you archive the copy, then you will no longer need to continually reauthorize your script in a new file, as the working file contains an authorized Apps Script project.
Create a template file, which has the corresponding sheets you would like to start each day with
Write a script which will perform 2 tasks
Export the current state of the active workbook to a new workbook (or even a PDF or other archive-ready asset)
Replace the contents of the active workbook with those from the template workbook.
Run this script either manually or from a time-based trigger.
I'm trying to modify this script so that once a day it runs exporting the result to my drive and overwriting the file that is there. I'm completely new to google scripts so this might be a very basic request. To clarify, i know how to set a tim trigger. I'm looking for how i edit the script so that it writes then overwrites the file to my drive on the timetrigger