Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:59:46+00:00 2026-06-04T04:59:46+00:00

i am trying to create a google document that has a paragraph automatically generated

  • 0

i am trying to create a google document that has a paragraph automatically generated from data on a google spreadsheet. most of the information i have found shows how to create one document or one page for each set of data but i need to generate one paragraph and have the script create as many pages as is necessary. this is my first google script (and i’m new to scripting in general) so there may be some obvious errors.

here is what i have for the script so far:

function scriptListGen() {  

  var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();  
  var firstName = mySheet.getRange("B3").getValue();  
  var lastName = mySheet.getRange("C3").getValue();  
  var dispo1 = "Prescription Left With Dr.";  
  var dispo2 = "Prescription Recieved";  
  var dispo3 = "Prescription Denied";  
  var notes = "Notes:"; 
  var date = "Date:";  
  var content = firstName + " " + lastName + "  " + dispo1 + dispo2 + dispo3 + notes;  

  var templateDocID = ScriptProperties.getProperty("listTemplateDocID");  
  var docID = DocsList.getFileById(templateDocID).makeCopy().getId();  
  var doc = DocumentApp.openById(docID);  
  var body = doc.getActiveSection();  
  body.insertParagraph(1, content);  
  body.insertHorizontalRule(2);  
}  

any help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:59:47+00:00Added an answer on June 4, 2026 at 4:59 am

    Evan,
    I’m not quite sure what you mean by ‘add as many pages as possible’. But assuming you mean that you want to have the information from your spreadsheet flow from one page to the next as needed, I think you’ll want to use

    body.appendParagraph  rather than insertParagraph.
    

    Here’s some code I’m using that does a similar process.

    function ReadFromSelectedTab(doc,SelectedTab,lHeading2style,lHeading3style,CatCount)
    {
    var doctoprocess = UserProperties.getProperty('doctoprocess');
    var workbook = SpreadsheetApp.openById(doctoprocess);
    var sheets =  workbook.getSheets();
    var sheet =  workbook.getSheetByName(SelectedTab);
    
    
    if (sheet != null) {
    // The code below will make the sheet active in the active workbook
    workbook.setActiveSheet(workbook.getSheets()[sheet.getIndex()-1]);
    var lastRow = workbook.getLastRow();
    var lastColumn = workbook.getLastColumn();
    var lastACell = workbook.getRange("A"+lastRow);
    Logger.log("Last Column: " + lastColumn)
    for (var q = 0; q < lastRow; ++q)
         {
    var Category = sheet.getRange(q+1,1).getValue();
    var Question1 = sheet.getRange(q+1,2).getValue();
    var Question2 = sheet.getRange(q+1,3).getValue();
    
    var Column3Heading = sheet.getRange("C1").getValue()
    if (Column3Heading = 'ANSWERS')
    {
    var answers = true;
    }
    if (Category.length > 0) {
    **var head2 = doc.appendParagraph(CatCount +".  " + Category);**
    
    head2.setHeading(DocumentApp.ParagraphHeading.HEADING3); 
              doc.appendParagraph(" ");
           CatCount++;
         }
         if (Question1.length > 0) {
           var quest1 = doc.**appendParagraph**(Question1);
           quest1.setAttributes(lHeading2style);
         }
         if (Question2.length > 0 && q>0) {
    
           var quest2 = doc.appendParagraph("     " + Question2);
           if ( answers != true)
           {
           quest2.setAttributes(lHeading3style);
           }
           else
           { quest2.setItalic(true).setFontSize(8).setBold(true); }
         }
    
       }    //  for (var q = 0; q < lastRow; ++q)
    }          //  if (sheet != null) 
    }
    

    So the code will iterate through tabs I selected, and then go through the various rows to pull out information. The information is formatted using some pre-defined headingstyles into a Document.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom javascript class that inherits from google.maps.Map (V3 API).
I am trying to fetch the data from a google docs spreadsheet and I
I am trying to create Google Chrome extension that will send interesting links to
I have been trying to create a new google custom search engine, but when
I'm trying to create an application that uses Google OAuth for login, and then
I'm trying to create an application that uses the iPhone MapView (under Google Code).
I am trying to set Google Chart using API generated from below link Google
I am trying to use the Google Charts API to create a chart that
I'm trying to create a Google Map with multiple markers on it, that loads
I am trying to create a simple javascript based extension for Google Chrome that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.