Extend Google Docs, Sheets, and Forms with Apps Script

While macros are currently not supported in Google Docs, Sheets, or Forms, you can extend the capabilities of documents, spreadsheets, and forms by adding custom menus, dialogs, and sidebars with Google Apps Script, a simple yet powerful scripting language based on JavaScript. In Google Sheets, Apps Script also lets you write custom spreadsheet functions.

Apps Script also allows you to build web applications and interact with many other Google services, including AdSense, Analytics, Calendar, Drive, Finance, Gmail, and Maps.

Apps Script for beginners

If you’d like to learn Apps Script but you’re new to programming, Codecademy offers a great online JavaScript course for beginners. (Note that this course was not developed by and is not associated with Google.) Once you feel like you have a handle on JavaScript, try either of these Apps Script quickstart tutorials: Macros, menus, and custom functions or Managing form responses.

You can also check out our gallery of Add-ons, script-based tools built by third-party developers, available in Google Docs and the new Google Sheets.

Apps Script for experienced programmers

Experienced developers should start with a quick introduction to Apps Script’s development environment. After that, the list of tutorials should give you a good idea of what’s possible, or you can jump straight into the reference documentation. We can’t wait to see what you build.

Custom menu items

Custom menus let you add new functionality to the familiar menu system. When the user clicks on a menu option, Apps Script runs a series of instructions (a macro) determined by the script’s author.

For example, a custom menu could include a command that produces a simple report from the data in a spreadsheet and then sends it in an email. This allows users to run scripts without opening the Script Editor or typing a formula.

To learn more about custom menu items and dialog boxes in Sheets, try this tutorial: Defining Spreadsheet Menus. To learn more about custom menu items, dialog boxes, and sidebars in Docs, see the guide to Extending Docs with Apps Script. You can customize the Google Forms editor using exactly the same techniques as Docs, but note that these customizations are only visible to the person who is creating the form, not in the view that form respondents see.

Apps Script in Sheets

Custom functions

A custom function (sometimes called a user-defined function) is similar to a spreadsheet formula like ‘=SUM(A1:A5)’ except that you define the formula’s behavior in Apps Script. For example, you could create a custom function, in2mm(), that converts a value from inches to millimeters, then use the formula in your spreadsheet by typing ‘=in2mm(A1)’ or ‘=in2mm(10)’ into a cell.

To learn more about custom functions, get started with this tutorial: Custom Functions in Spreadsheets.

Apps Script gallery

You don’t need to write a single line of code to use Apps Script with Google Sheets — instead, you can try using scripts that have been created by fellow users. Check out Add-ons, our collection of popular scripts.

Mary is a Docs & Drive expert and author of this help page. Leave her feedback below about the page.

Was this article helpful?