Google I/O 2013 - Extend Google Docs with Apps Script

Google for Developers · 11K views · 2013 · 35:53

Open on YouTube

Python, Ruby & scripting languagesWeb developmenttalkdated

Why Stack Overflow recommends it

Stack Overflow users link it as a reference for what Apps Script can do in Google Docs, including text handling and the then-upcoming cursor and selection support.

Recommended by 0 people across 0 different months, 2013 to 2015.

What it is

A Google I/O 2013 session in which Jonathan Rascher and Saurabh Gupta show how to use Google Apps Script to extend Google Docs with custom menus, popups and workflows. It covers importing data from other sources and integrating your own applications into Docs.

What people said

Cites Bryan P · 2013-05 · Stack Overflow · on “Get user-selected text”

If you want to retrieve text you've highlighted, could try... function findHighlighted() { var body = DocumentApp.getActiveDocument().getBody(), bodyTextElement = body.editAsText(), bodyString = bodyTextElement.getText(), char, len; for (char = 0, len = bodyString.length; char < len; char++) { if (bodyTextElement.getBackgroundColor(char) == '#ffff00') // Yellow Logger.log(bodyString.charAt(char))} } Derived from Jonathan's I/O example [this video] . However, note that working with cursor position and selections [this video] is not yet available as of this writing. UPDATE: Cursor selection is available now, see docs [LINK] .

Cites user1475265 · 2013-06 · Stack Overflow · on “How to find where user's cursor is in Document-bound script”

As of right now, this is not possible. If you watch the "Extend Your Script to Google Docs" video, they mention that this feature will be available soon though: [this video]

Cites Matt Varner · 2015-02 · Stack Overflow · on “Why does Google Apps Script throw 'ReferenceError: "bold" is not defined' when using .setBold()?”

The context : I need to process/correct many text documents containing multiple particular textual errors, highlight keywords in 'bold' and then output the result. I have a Google spreadsheet with two worksheets: one with two columns of ' wrong wordforms ' and ' replacement wordforms ' (2d array) that I intend to add to over time and use it as a datastore to 'call from;' the other, a single-column collection of words (1d array) I designate "keywords" to check for and then highlight in the target documents. Things I've tried that worked : I used a basic array iteration loop from a beginner video (I can't add more links yet, I apologize) and swapped in body.replaceText() for the sendEmail() ,