Accessing and Modifying Google Docs

Learn Google Apps Script – Free Source Code Guide Coding exercises and more Free Apps Script Lessons by Laurence Svekis Google Developer Expert in Workspace (GDE) This code modifies a Google Document by applying some formatting to specific paragraphs. The first line defines a variable id that stores the ID of the Google Document that will be modified. The second line opens the Google Document with the given ID using the openById method of the DocumentApp class, and assigns it to the variable doc. The third line gets the body of the document using the getBody method of the Document class, and assigns it to the variable body. The fourth line gets all the paragraphs in the document using the getParagraphs method of the Body class, and assigns them to the variable paras. The fifth line defines a JavaScript object called style that will be used to apply the formatting. The object has two properties: BOLD and FONT_SIZE, which are constants defined in the Attribute enum of the DocumentApp class. The BOLD property is set to true, and the FONT_SIZE property is set to 18. The code then iterates over each paragraph in the document using a forEach loop. For each paragraph, it checks if the text of the paragraph contains the string “Lorem ipsum” using the indexOf method of the String class. If the string is found (i.e., indexOf returns a value greater than or equal to 0), the code applies the formatting defined in the style object to the paragraph using the setAttributes method of the Paragraph class. Once the loop has finished, the code exits and the modified document is saved automatically. Course content web development and web design courses with coding examples and source code for the lesson content. Source Code is available within my Github account. Lessons posted are designed to help students learn more about a specific topic related to modern web development and applying code. Laurence Svekis is a professional top selling course author having instructed over 1 Million students both online and in person. Laurence Svekis is a Google Developer Expert specializing in Google Workspace automation using Google Apps Script Code. Check out my Website for more details at #GoogleAppsScript #GAS #AppsScript #GoogleScript #GoogleSheets #GoogleDocs #GoogleForms #GoogleSlides #GoogleWorkspace #GSuite #GSuiteEdu #GoogleEdu #onlinecourses #elearning #distancelearning #onlinetraining #learningonline #onlineeducation #MOOCs #virtuallearning #edtech #educationtechnology #learningsolutions #traininganddevelopment #professionaldevelopment