- Learning Google Apps Script
- Ramalingam Ganapathy
- 509字
- 2021-07-16 12:40:01
Google Apps Script
You can customize or automate Google Apps using the JavaScript scripting language with Google-defined classes, known as Google Apps Script (GAS). Google implements GAS based on JavaScript 1.6 with some portions of 1.7 and 1.8. The GAS services and APIs provide easy access so users can automate tasks across Google products and third-party services.
You can write code in Google Docs, Sheets, and Forms using GAS and can automate tasks similar to what Visual Basic for Applications does in Microsoft Office. However, GAS runs on Google's server and the results are rendered in your browser. The integrated script editor allows you to edit and debug your scripts within your browser, and you do need not install anything. You can activate your debugged and tested script functions to run either based on your interactions or based on a trigger in response to an event or timed intervals (in minutes, hours, days, weeks, future dates, and so on). These events include onOpen
, onEdit
, onInstall
, and many more. GAS is also used to create add-ons for Docs, Sheets, and Forms.
GAS can help you with every aspect of automating a task—you can even use it to order a pizza at predetermined date/time!
Visual Basic for Applications
Microsoft implements Visual Basic for Applications (VBA) to help automate Office applications such as Excel and Word. For each respective application, VBA is known as Excel VBA or Word VBA and so on. Using Excel VBA, you can create macros for Excel known as "Excel macros". GAS is for Google Applications, and operates in the same way as VBA does for Microsoft Office applications. Although both VBA and GAS do not require a separate compilation process, they are very different scripting languages and use different programming APIs, methods, and properties.
I hope many of you are familiar with using VBA for Office applications; if not, then never mind—that's not an obstacle to learning GAS.
The advantages of GAS over VBA
- Version-independence: Sheets/Docs along with scripts are automatically saved in the cloud, attached to your Google account, and accessible from any computer with a browser. There is no need to worry whether the other computer has the same version of Sheets/Docs installed or not, whereas we can never be sure that one version of the Excel/Word macros will work on another version.
- Platform-independence: When you create VBA macros in Excel/Word on the Windows platform, they may not work on the Mac platform and vice versa. With Google Sheets/Docs, it doesn't matter what platform you're working on—it'll work.
The limitations of GAS
GAS runs on Google's server, so it cannot run continuously for more than six minutes (this may vary in the future). All of your functions should finish running and should return results within this time limit. Don't panic, as you'll learn how to use triggers effectively to overcome these limitations later.
In the following sections, we will take a look at the most popular Google Apps and how we can use GAS to customize and/or automate tasks.
- JavaFX Essentials
- 教孩子學編程:C++入門圖解
- Learning DHTMLX Suite UI
- 網站構建技術
- Java EE 8 Application Development
- 數據結構案例教程(C/C++版)
- Java程序設計入門
- Extending Puppet(Second Edition)
- PHP從入門到精通(第4版)(軟件開發視頻大講堂)
- HTML+CSS+JavaScript網頁設計從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- Emotional Intelligence for IT Professionals
- 測試架構師修煉之道:從測試工程師到測試架構師
- Ext JS 4 Plugin and Extension Development
- Python Digital Forensics Cookbook
- Visual C++程序設計與項目實踐