How to Add an Apps Script to Your Google Applications?

Video how to add app script to google sheet

Do you want to add additional features to your Google documents and have come across an Apps Script on the web? But you’re not sure how to use it? Well, you don’t need to be a programmer to do so! Having a basic understanding of how to add an Apps Script from the web is enough. You don’t need to dive into the code unless you’re genuinely interested in how it works.

This beginner’s tutorial is for both technical and non-technical individuals, and it will teach you how to add an Apps Script to Google Docs/Sheets/Forms/Slides. I’ve tried to explain it in simple terms, without any technical jargon.

Step 1: Determine the Type of Google Application the Apps Script Runs On

Ask yourself: What does the Apps Script do? Does it interact with Google Docs/Sheets/Forms/Slides?

Adding a script to the wrong application will render the script useless.

Step 2: Open Your Document and Open the Script Editor

The four productivity programs have a script editor menu in the menu bar. It’s usually found under Tools > Script Editor. For Google Forms, it’s located within the three-dot menu.

Google Docs Script Editor Menu

The menu of the script editor in Google Docs

Google Sheets Script Editor Menu

The menu of the script editor in Google Sheets

Google Slides Script Editor Menu

The menu of the script editor in Google Slides

Google Forms Script Editor Menu

The menu of the script editor in Google Forms

Step 3: Add the Apps Script

  • After clicking on the Script Editor menu, the script editor will open in a new tab.
  • Follow the steps shown in the screenshot below:
    1. Give a name to the script. A short name that describes what the script does is sufficient.
    2. Copy and paste the script you found on the web into the editing space.
    3. Click the Save button. Check for any typos or errors in the script. Hopefully, there aren’t any.

Script Editor Interface

The interface of the script editor

Don’t have a script at hand? Try this one:

function onOpen() { 
  var ui = SpreadsheetApp.getUi(); 
  ui.createMenu('xFanatical')
    .addItem('Say Hello', 'sayHello')
    .addToUi(); 
}

function sayHello() { 
  SpreadsheetApp.getUi()
    .alert('Hello you, welcome to xFanatical'); 
}

In addition to the script file, some Apps Scripts might also contain HTML files. You can easily add them by going to File > New > HTML File. Then, simply paste the HTML content.

Insert HTML File in Google Apps Script Editor

Insert HTML file in the Google Apps Script editor

A more complex Apps Script project may contain multiple script and HTML files. So make sure to copy all the source code into the script editor.

Complex Apps Script projects contain multiple files

Complex Apps Script projects contain multiple files

Step 4: Run the Script Now

  • Go back to the tab of your Google document.
  • Refresh the page.
  • You will see additional menus added to your Google documents/sheets/slides/forms, as shown below. Depending on the functionality of your Apps Script, you will see different menus. Try running the script.

Custom Menu Created by xFanatical in Google Sheets

The additional menu added by the Apps Script

  • Authorization: If an Apps Script requires access to sensitive data from your Google account, a dialog box will appear for the first time. We assume that the Apps Script you downloaded from the web is not malicious, but contact us if you’re unsure. If you know it’s safe, follow these steps:
    1. In the Required Authorization dialog, click Continue.
    2. In the Choose an account window, sign in with your Google account on which the Apps Script will run.
    3. A warning window may appear stating “This app isn’t verified.” Click Advanced and then click Access xxxx (unsafe).
    4. You will now see the permissions requested by the Apps Script. Click Allow.
    5. You have now completed the authorization.

Authorization Required Dialog

Authorization required dialog

Sign in with your Google Account to use the Apps Script

Sign in with your Google Account to use the Apps Script

Warning "This app isn't verified"

Warning “This app isn’t verified”

Permissions requested by the Apps Script

Permissions requested by the Apps Script

  • The Apps Script is now officially running. See what you get with the example script I shared above. A popup window will appear with the message “Hello you, welcome to xFanatical”.

A popup window appears in Google Sheets when running the Apps Script

Final Demo: Hello xFanatical

Congratulations! You have learned how to add an Apps Script to your Google documents to add additional features. Now, explore free or premium Apps Scripts on Crawlan.com to optimize your Google documents according to your business needs.

If you’re interested in programming, play around and have fun with Google Apps Script.

Still confused after this tutorial? Leave a comment below.

Related posts