Creating and Updating Google Docs with Apps Script:

Опубликовано: 28 Февраль 2023
на канале: Laurence Svekis
3,412
26

Generate Google Docs:
Google Docs is a cloud-based word processing tool that allows users to create and edit documents. With Apps Script, you can programmatically generate Google Docs, populate them with data, and format them. The code below creates a new Google Doc and adds a paragraph of text.
https://basescripts.com/apps-script-c...

The createmyDoc() function and the updatemyDoc() function both manipulate a Google Docs document. Here's what each function does:

createmyDoc(): This function creates a new Google Docs document titled "Laurence Svekis", inserts a paragraph into the document, and sets the text of the paragraph to "My new Doc, Laurence Svekis". Here's what each line of the function does:
const doc = DocumentApp.create('Laurence Svekis');: This line creates a new Google Docs document titled "Laurence Svekis" using the create() method of the DocumentApp class. The create() method returns a Document object that represents the newly created document.
const body = doc.getBody();: This line gets the Body object of the newly created document using the getBody() method of the Document object.
body.insertParagraph(0,'My new Doc, Laurence Svekis');: This line inserts a new paragraph at the beginning of the document using the insertParagraph() method of the Body object. The insertParagraph() method takes two arguments: the position where the new paragraph should be inserted (in this case, the beginning of the document), and the text of the paragraph ("My new Doc, Laurence Svekis" in this case).

updatemyDoc(): This function updates an existing Google Docs document by inserting a new paragraph into it. Here's what each line of the function does:
const id = '1JJyHruUbZQv5LHTVebDDbs';: This line sets the id variable to the ID of the Google Docs document that we want to update. This ID is a unique identifier that is assigned to each Google Docs document.
const doc = DocumentApp.openById(id);: This line opens the Google Docs document with the specified ID using the openById() method of the DocumentApp class. The openById() method returns a Document object that represents the opened document.
const body = doc.getBody();: This line gets the Body object of the opened document using the getBody() method of the Document object.
body.insertParagraph(10,'*****Laurence Svekis');: This line inserts a new paragraph at position 10 (i.e., after the tenth paragraph) in the document using the insertParagraph() method of the Body object. The text of the new paragraph is "*****Laurence Svekis". The insertParagraph() method takes two arguments: the position where the new paragraph should be inserted (in this case, after the tenth paragraph), and the text of the paragraph ("*****Laurence Svekis" in this case).


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 https://basescripts.com/
Subscribe    / @laurencesvekiscourses  

Tags and Keywords

#GoogleDocs #GoogleAppsScript #documentcreation #documentediting #scripting #automation #productivity #GoogleDrive #collaboration #workspace #virtualwork #cloudcomputing #technology #coding #programing #customfunctions #APIs #GoogleWorkspace #Gsuite #GoogleDriveAPI #GoogleDocsAPI #documentmanagement #documentautomation #teamwork #cloudstorage #filemanagement #webapps #webdevelopment #webdesign #backenddevelopment #fronteddevelopment #fullstackdevelopment #GoogleDevelopers #TechSkills #codinglife #learningtocode #developmenttools #appdevelopment #softwareengineering #webapplication #digitalworkspace #projectmanagement #workflows #documentprocessing #workflowautomation #datamanagement #GoogleSheets #GoogleForms #GoogleSlides #GoogleCloudPlatform #GCP #GoogleAppEngine


Смотрите видео Creating and Updating Google Docs with Apps Script: онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Laurence Svekis 28 Февраль 2023. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 3,412 раз и оно понравилось 26 посетителям.