Teacher Tech

Paperless Is Not A Pedagogy

Menu
  • Teacher
    • Blog Posts
    • Teacher Tech Facebook Group
  • Google Certified Innovator
    • CoffeeEDU
    • Tour of Google Classroom
    • Back to Classroom
  • Author
    • Alice Keeler Books on Amazon
    • Bulk Order Books
  • Developer
    • Schoolytics
    • Google Developer Expert
    • Add-ons By Alice Keeler
      • Doc to Slides by Alice Keeler
      • Roster Extras by Schoolytics
      • TemplateTab
      • toTabs
      • Form Printer
      • Quiz Helper
      • Dice Slides by Alice Keeler
      • Scheduler by Alice Keeler
      • Document Outline by Alice Keeler
      • Missing From (Google Forms™)
      • Randomize Slides by Alice Keeler
      • Speaker Notes by Alice Keeler
      • sheetPusher
      • Seating Chart Slides
      • Hyperlink Slides Choice Board
      • Add-a-Date
      • QuickShare Screenshot
      • Anyone Can View
      • Drive 20
    • Apps Script Tutorials
    • Templates
  • EdTech Coach
    • Premium Membership
    • Free Newsletter
  • Hire Alice
Menu

New! Extensions Menu in Google Docs

Posted on May 2, 2022May 2, 2022 by Alice Keeler

First Google Sheets™, now Google Docs™. The menus are changing!! Let’s be honest, it is really annoying when the different product’s menus do not match. As of this week, Google Docs is going the way of Google Sheets to have an “Extensions” menu instead of an “Add-ons” menu. Yay! Speaking of Add-ons, I have over a dozen Add-ons I have personally coded. So the Extensions menu is where you can find “Doc to Slides” and “Document Outline.”

Extensions menu in Google Docs showing add-ons and Apps-Script  New! Extensions Menu in Google Docs
Install Alice Keeler Add-ons

Things Have Moved

With the new Extensions menu, the Add-ons menu is now just an item under the Extensions. Items that were under tools have moved as well. Script editor, which I use a LOT, has moved from the Tools menu to the Extensions menu and is now labeled as “Apps Script.”

Tools

The new Tools menu is honestly things I only use occasionally. It is good to become familiar with what is available in the Tools menu for when you need it. Word Count, Translate Document, and Voice Typing are some highlights of the Tools menu.

Tools menu with spelling and grammar, word count, review suggested edits, citations, etc...

What is Apps Script?

You can CODE Google Docs™! That is what my Add-ons do. Provide extra functionality to Google Docs (or Sheets, Slides, Forms, etc…). To get started with Coding Google Docs you want to use that Extensions Menu.

Script Editor – IDE

Clicking on “Apps Script” in the Extensions menu takes you to the coding environment. Use this IDE to make your own custom Add-on. Click on where it says “Untitled project” to name your Add-on. This script is what is called “bounded.” It is bounded to this particular Google Doc. What this will allow you to do is to share the Google Doc with the code. Anyone who copies the document, also copies your Add-on.

Copy Sample Doc with Code

Make a Menu

An Add-on needs a menu to allow users to access the functionality of the coded script without having to look at the code.

onOpen

It is important that the name of your function for the menu is called onOpen(). This signals to the Google Doc that upon opening the Google Doc that the menu should automatically load. When starting your menu you want to identify what you are coding a menu for. DocumentApp or SpreadsheetApp or SlidesApp. Press period to show a list of options. What you are looking for is .getUi(). This is the user interface. The user interface is buttons, menus, sidebars, pop up alerts, etc…

function onOpen() {
 DocumentApp.getUi()
 .createAddonMenu()
 .addItem()
 .addToUi(); 
}

A Second Function

The function onOpen() only creates the Add-on menu. You will need a second function that will perform an action within your Google Doc.

Each function is encapsulated by a set of {curly braces.} After the ending brace, press enter several times and type the word function all lower case. Then a space, followed by your function name. You can name it whatever you want (mostly) so long as it is one word (no spaces, no funky characters).

You want to start each function, usually, with what Google Workspace App you are using. In this case we are still using DocumentApp. Press period to find the option of “.getActiveDocument().” You will need to end the line of code with a semicolon.

function addAParagraph(){
let doc = DocumentApp.getActiveDocument();  }

Variables

Variables are a super important part of coding. You define a variable, something you want to store, by using one of 3 things.

  • const doc = DocumentApp.getActiveDocument();
  • let doc = DocumentApp.getActiveDocument();
  • var doc = DocumentApp.getActiveDocument();

const, let, and var are different options that essentially do the same thing. Personally, I am trying to get used to using let more often since I frequently choose var. To get started it will not matter which of the 3 you use. As you improve your JavaScript and Apps Script skills you will want to choose which of these 3 options makes the most sense. I am introducing all 3 options to you to do as being interchangeable so that if you look at sample code and someone defines their variable with const instead of var you will know it does the same thing.

However you call your variable you will want to use that variable to reference the current active document and then press period.

Document Body

There are 3 parts to a Google Doc. The Header, the Body, and the Footer. You need to be specific as to which part you are wanting to focus on. Define another variable for the document body. Choose any of the 3 options for calling a variable and define the body by using the previous variable and pressing period to find “getBody().” Note, this is case sensitive.

function addAParagraph(){
let doc = DocumentApp.getActiveDocument();
const body = doc.getBody();  }

Append Paragraph

I use append paragraph a lot when coding Google Docs. It adds a paragraph to the bottom. It will seem like a silly thing to do in this context since it would legitimately be faster to type the paragraphs into the Google Doc. An example of how I used append paragraph recently was I was helping out with the “Adulting day” event at my school. Each student is assigned 9 thirty minute sessions. To share the schedule with students I wanted to grab off the spreadsheet the first session and append it to the student Google Doc. Then I wanted to append the 2nd session, etc… And I needed to do this over 400 times. You can see how code is much nicer than copying and pasting 9 sessions over 400 times!

The variable I defined for body I will need to use to appendParagraph. On the next line type the variable for the Document body and press the period to select “appendParagraph().”

Test String is in Single Quotes

The word string is very important for coding. It means a string of characters… or in other words, some text! You need to make sure your text is in single quotations. Notice the text turns red when you surround it by quotes. Within the parenthesis for the appendParagraph method type in a phrase you want to append to the document.

Add Your Function to the Menu

Once your function is complete you will want to modify the onOpen menu to include your function. The dot addItem is a text string (single quotes) of what the user will see in the menu. Then a comma outside of the quotations. Then, also in single quotes, the name of the function that is being called.

//This is a sample function for how to create an Add-on menu in your Google Doc.  function onOpen() {
 DocumentApp.getUi()
 .createAddonMenu()
 .addItem('Add a Paragraph','addAParagraph')
 .addToUi(); 
}  //This is the second function that will run from the menu  function addAParagraph(){
let doc = DocumentApp.getActiveDocument();
const body = doc.getBody();
body.appendParagraph('Hello World');  }

Save and Run

Click the save icon (Control S) and press the Run icon (a triangle). You will be prompted to authorize the Add-on. You are only authorizing yourself access to your own documents. After saving, running, and authorizing the onOpen menu notice that it is now part of the Extensions menu. Also, notice the icon is slightly different than your other installed icons. This is letting you know it is a bounded script to the document and not an approved Add-on by Google.

extensions menu in the Google Doc. Notice the unofficial Add-on for Coding Tutorial by Alice Keeler

Select the menu item and see that it will add your paragraph each time you select it!

Get Started

This is far from a complete tutorial on how to use the Apps Script option in the Google Docs Extensions menu. However, I hope this helps get you started with knowing that it is possible to code and customize Google Docs. Do a tutorial on JavaScript and check out the tutorials on Google Apps Script.

  • Google Classroom: Filter Gmail for Private Comments
  • Google Docs: Prompt Students to Make a Copy
  • Coding Google Apps – Get Started
  • Google Apps Script: Getting Started Part 2
  • 5 Basics to Know for Coding
Add-Ons
Grab a Spreadsheet Cell from Each Student

on 26 May, 2022 by Alice Keeler

Finally! A way to grab a spreadsheet cell from individual student spreadsheets. This allows you to easily review all students responses to a question in one place.

Forms
Award Badges to Your Students with Certify’em

on 24 May, 2022 by Alice Keeler

Gamification works! Use Google Forms to award students badges using the Forms Add-on Certify’em

Drive
Help! I Am Moving Schools. How Do I Move Google Drive Files?

on 24 May, 2022 by Alice Keeler

How do you copy or move Google Drive files? If you are retiring or moving schools or simply want a backup of your school files here are 5 ways you can move Google Drive files.

Add-Ons
How to Update Student Spreadsheets

on 22 May, 2022 by Alice Keeler

You make a copy of a spreadsheet per student, but what if you have a typo or want to add to the spreadsheet? sheetPusher by Alice Keeler and Heather Lyon helps you update student spreadsheets. Here is…

Docs
Google Docs Google Play App Store Install

on 21 May, 2022 by Alice Keeler

If you use Google Docs you want to be sure to have the mobile version as well. Use google play app store install

Related

Related Alice Keeler Blog Posts:

  1. Google Classroom: Pull Student Paragraphs and Give Feedback
  2. Bring In a Google Doc into a Spreadsheet
  3. Give Checklist Feedback in Google Docs using Google Keep
  4. SlidesMania with Doc to Slides by Alice Keeler

Continue Reading

Next Post:
How to Make a Rubric with Multiple Choice Grid in Google Forms
Previous Post:
Google Classroom Announce Missing Assignments

You must log in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Alice Keeler is a mom of 5. Current High School math teacher. Developer for Schoolytics.com. Google Certified Innovator, Microsoft Innovative Educator, Google Cloud Innovator Champion, and Google Developer Expert. Founder of #coffeeEDU
Teaching with Google Jamboard
Developer Schoolytics
Schoolytics is FREE for teachers.

Find ALL My Blog Posts


Link to List

Google Classroom Books

Alice Keeler: Mom of 5. Current High School math teacher. Developer for Schoolytics. Founder #coffeeEDU. Google Certified Innovator. Microsoft Innovative Educator. Google Developer Expert. EdTech Specialist.

My Referral Links


Custom Stickers, Die Cut Stickers, Bumper Stickers - Sticker Mule

 

©2022 Teacher Tech | Theme by SuperbThemes