Create new element from list item with specific text in it Google Apps Script in Docs

To modify the script to add each “Answer” item as a new line immediately following where it was removed, rather than at the end of the document, we need to adjust the logic to insert a paragraph right after the detected list item’s position. Here’s how you can do it: This script differs from the … Read more

Write a simple script to log a custom message in the Google Apps Script log

Write a simple script to log a custom message in the Google Apps Script log Instructions: Explanation: This script defines a function logMessage that creates a variable message containing a string. It then uses Logger.log() to print this message to the Google Apps Script log. function logMessage() {  const myName = ‘Laurence’;  const message = … Read more

Append a row of data to the end of the current sheet

Append a row of data to the end of the current sheet Instructions: Explanation: This script appends a new row to the bottom of the active sheet with the data provided in the rowData array. function appendMyRow(){   const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘Sheet1’);   const rowData = [‘New’,’Laurence’,’Svekis’];   sheet.appendRow(rowData);   //Logger.log(sheet.getName()); } Google Apps Script code snippet appends a … Read more

Use Google Apps Script to send an email to a specific recipient.

Objective: Use Google Apps Script to send an email to a specific recipient. Instructions: Explanation: This script uses the MailApp.sendEmail() method to send an email. It requires the recipient’s email address, the subject of the email, and the body of the email as parameters. Code: function sendMyEmail(){   const recipient = “email@gmail.com”;   const subject = ‘Test … Read more

Programmatically create a new Google Doc and insert text into it

Programmatically create a new Google Doc and insert text into it Instructions: Explanation: This script creates a new Google Doc titled “New Google Doc” and then inserts a paragraph of text into the document. Code: function createGoogleDoc(){   const paraContents = ‘My Name is Laurence Svekis’;   const doc = DocumentApp.create(‘New Google Doc’);   const body = doc.getBody(); … Read more

Read and log data from the first cell in a Google Sheets spreadsheet

Objective: Read and log data from the first cell in a Google Sheets spreadsheet. Code: function readSpreadsheetData() {   const ss = SpreadsheetApp.getActiveSpreadsheet()   const sheet = ss.getSheetByName(‘Sheet1’);   const range = sheet.getRange(‘A1’);   const value = range.getValue();   Logger.log(value); } Instructions: Explanation: This script gets the active sheet of the current spreadsheet, accesses cell A1, reads its value, and … Read more

50 Exercises 55 Quiz Questions Getting started with Google Apps Script

Check out our comprehensive guide on “Getting Started with Google Apps Script If you’re looking to level up your Google Apps Script skills, this guide is a must-read. It covers 50 Exercises and 55 Quiz Questions to help you become a scripting pro. 🤓 🔥 Here are some key objectives covered in the guide: #GoogleAppsScript … Read more

Update Docs page elements update finding a H3 and combine it with the next paragraph

Here’s a breakdown of how the code works: In summary, this script is designed to find Heading 3 paragraphs in the document, take the content of the next paragraph, and replace the content of the Heading 3 paragraph with it, effectively merging the two paragraphs while removing the original next paragraph.

Adjust line indentation with apps script in Docs

To adjust the indentation of list items properly in a Google Document using Apps Script, it’s essential to use the correct properties and methods. Unfortunately, the setIndentStart and setIndentFirstLine methods I mentioned earlier do not exist in the Google Apps Script Document service. For list items, you can adjust the indentation level via the setGlyphType … Read more