Sad to Happy

Make Google Forms Results Readable!

Google Forms is an excellent quick way to produce a form for polling, surveys, or gathering any data from any amount of people. It produces a nice spreadsheet of all the submissions to the form and even provides some basic analytics for the data. You may be thinking, “This is great! I can get all my friends to send me a lengthy explanation of the meaning of life through my Google Form and have it displayed nicely in a Google Spreadsheet!” Unfortunately my friend, you will be a little disappointed as the spreadsheet becomes virtually unreadable when long paragraph field entries are submitted. Fortunately, I created a neat little script that will convert the contents of any Google Spreadsheet into a Google Document!

UPDATE

Save As DocI recently published this script as a Google Sheets add-on. You can install it by clicking Add-ons > Get add-ons… in the Sheets menu. Then find Save as Doc and install it!

To get this setup follow these quick steps to start rocking your Google Forms world!

  1. In your Google Spreadsheet click Tools > Script editor…
  2. Copy the following script
    function saveAsDOC() {
         // Prompts the user for the file name
         var fileName = Browser.inputBox("Save DOC file as (e.g. myDOCFile):");
         
         // Check that the file name entered wasn't empty
         if (fileName.length !== 0) {
              // Create a file in the Docs List with the given name and the DOC data
              var doc = DocumentApp.create(fileName);
         }
         else {
              Browser.msgBox("Error: Please enter a DOC file name.");
         }
         
         // Get the range in the spreadsheet
         var ws = SpreadsheetApp.getActiveSpreadsheet().getDataRange();
         try {
              var data = ws.getValues();
              
              // Loop through the data in the range and create paragraphs with the appropriate heading
              if (data.length > 1) {
                   for (var row = 1; row < data.length; row++) {
                        for (var col = 0; col < data[row].length; col++) {
                             if(data[row][col]!=""){
                                  var section = doc.appendParagraph(data[0][col]);
                                  section.setHeading(DocumentApp.ParagraphHeading.HEADING4);
                                  doc.appendParagraph(data[row][col]);
                             }
                        }
                        
                        // Add a page break to end of each row, except for the last one
                        if (row < data.length-1) {
                             doc.appendPageBreak();
                        }
                   }
              }
         }
         catch(err) {
              Logger.log(err);
              Browser.msgBox(err);
         }
    }
  3. Paste the copied script into the Google Script editor
  4. Save the project and enter Save As Doc as the name of the project
  5. Close the project window and in your Google Spreadsheet click Tools > Script manager…
  6. Click the Save As Doc script and click Run
  7. After clicking Run for the first time Google will ask you to authorize the script to run.  Click Authorize and then Close in the new window that appears
  8. Finally, click Run again and enter a name for the Google Document that will be saved in your Google Documents List.

Enjoy!

40 Comments

  1. Jana says:

    James! You are da MAN! OMG…seriously….you just made my YEAR! i was so frustrated in my grad school work trying to get this dang google spreadsheet to output in a readable way, with each header rown repeating for EVERY response. I am SO very happy I happened upon your post. THANKS very, VERY much for taking the time to share. And now, I’ve got the script saved for future reference.

    Thank You Again!

    Best ~ Jana Tate
    Austin, Texas

  2. Marcel says:

    Hi James,
    great script, but I get this error message:
    Missing } after function text. (line 1, file ‘Code’)
    Do you know what I could do about this?
    thanks,
    Marcel

  3. James Bowles James Bowles says:

    Hi Marcel,
    This most likely means one of two things, an extra opening curly brace ‘{‘ was left when pasting the script into the script editor, or a closing curly brace was missed when copying the script. My suggestion is to delete everything from the script editor and copy and paste the code again being sure to copy everything in step 2.
    One thing of note is this only works on the spreadsheet view of form responses, not the form itself.

  4. Kathryn odell says:

    This is exactly what I have been looking for! Unfortunately, I am having the same experience as a previous poster:
    Missing } after message body (line 1 file” Code”)
    I pasted everything (from “function” to the two “} }” into the first line of the script editor. Any suggestions?

  5. Kathryn Odell says:

    Your script works great once you know one extra piece of information! When you copy the script, you will need to make sure each line starts exactly like your script, above. That means you need to take a few extra minutes to hit return in the appropriate spots. Thank you for your work!

  6. Izhar Aazmi says:

    Hey mate, thanks a lot and lot more than that. And may I please improve it more and publish it as an App for everyone to use?
    Please reply soon!

  7. James Bowles James Bowles says:

    Izhar,
    I plan on publishing this myself soon. Any ideas for improvement would be appreciated!

  8. Matt Green says:

    James! Thank you for posting this! I’m having trouble and hoping you might have a suggestion for me.

    It works great but each time I try to use it on a new document I have to re-create it. Any ideas on what I might be doing wrong?

    Thanks!!!

    Matt

    • James Bowles James Bowles says:

      Hi Matt,
      Since this is just a Google Spreadsheets script, it is only associated with the single form results spreadsheet it was added to. So, unfortunately, you will need to add it to each form results spreadsheet you wish to make readable. Glad you like it!

  9. ayt says:

    Thanks so much for this script James!

    I run a program that uses Google Forms to collect applications with long essay responses. This script makes it much easier to evaluate the applications.

    I wonder if it would be possible to alter the script so that the resulting Google Document would also have a table of contents of the submissions? I figure that this would involve:
    – switching the headers to be normal text (bolded?) so that they don’t get caught in Google Doc’s Table of Contents feature
    – adding script language that would look for the item under a specific column (ex. “Name” or Column A) and make that text a header so that it shows up in the Table of Contents
    – Add a Table of Contents to the beginning of the Google Doc

    I don’t know how to code, but I’m slowly learning with CodeAcademy. All I’ve managed to do so far is switch the headers to normal text. I’m stumped on the rest. Thoughts?

  10. […] to students.[2] (Alternatively, you can use a script within Google Drive to do the same; see https://ctl.mesacc.edu/blog/make-google-forms-results-readable/. A big thanks to Miriam Posner for posting this to Twitter!) You can also combine all submissions […]

  11. Thank you so much for sharing this. Seriously. Changing my workflow. Very appreciative. I’m going to share this with so many people!

  12. […] reformat them from an unreadable Google Spreadsheet into a clean-looking Google Doc (using this handy script), remove the names, and evaluate them that […]

  13. […] them from a relatively hard-to-read Google Spreadsheet into a clean-looking Google Doc (using this handy script), remove the names, and evaluate them that way” he says on the […]

  14. Jen says:

    THANK YOU! I just spent 25 minutes looking for this post again. Anyway, I have saved the instructions in my drive for future reference. 🙂

    • James Bowles James Bowles says:

      Hi Jen,
      I created a Google Sheets add-on that accomplishes this task. I recommend using the add-on versus this script I wrote.

      • RB says:

        Hey, I do have the add-on, but it is not responding and now I have an issue because I use the Google Form as a Lesson Plan recorder. I was taking the information from the sheet and converting it to a DOC and dispersing it to my teachers for use in their classes. Now, it has stopped working, is it possible there is an update that has caused it to stop working since Wednesday March 4th? That is the last day that I used it successfully. I tried yesterday and today without success.

        Thank you for your help and response,
        R

  15. Jon says:

    I tried to find your add-on view the Sheets menu, but you never give a name here to look for it amongst the other options. I tried another service, but if you help me find your I might try it, too.

  16. Data Append says:

    Thank you so much for sharing this. Seriously.

  17. Andrew says:

    This worked so great and was exactly what I was looking for. Thanks for sharing!

  18. Rohit says:

    I am an intern and was looking at making a nice impression by automating the weekly status accomplishment process.
    As a bright light idea, I thought of making a Google form and sending it across the team.
    Unfortunately, my manager would have to collect the responses and format them after I leave, later on, at the end of summer.

    This Add-On has made life much much easier and earned me an Intern Idea of the Summer award! (Just kidding) 🙂

    Add 1 more to the zillion and counting Thank you list!

  19. I love you, man! At last I can read all that the parents are telling me about their child who is a struggling reader. With these kids, everything the parent can tell me is valuable, and I was missing pieces and not getting the full picture until I found YOU!

    You ought to put a donation thing on the page, because I’d give you a small amount for sure! Small because I’m a teacher who spends all her money on the kids! As do so many.

    Anyway, wow…what an incredible help this script (now an Add-on) is. You amaze me!

    Thank you.

  20. praneeth says:

    Thanks a ton. Amazing script , makes the work so easy.

  21. Allison says:

    Thank you so much for this! You are my hero!

  22. Chemene says:

    Thank you so much!! I was the picture on the left until I found this post. Now Im the picture on the right!

  23. Larissa says:

    Thank you so very much!

  24. Marti says:

    Any way us non-programmers can do this? I developed a form no problem – the data gets output to a spreadsheet no problem… But now I have no clue how to implement any of these “fixes” because I am a just a non-programming laymen and don’t know what a script is or what to do with one…

  25. Matt says:

    This is fantastic… And thanks for making it easy by creating the add-on!

    Is there any way to set it up to run automatically whenever a new form submission comes in? That would be over-the-top great!

  26. kvn says:

    You are a lifesaver! Thank you so much, James! I am telling sharing this with all my friends!

  27. Bue says:

    Needed to qualitatively analyze all posts from a blog for my sociology thesis and was only able to get a csv from the scraper (which was much more cumbersome to work with). Your script perfectly fitted into the last step of my process. Thanks a lot 🙂

  28. Andrea Hernandez says:

    Thank you!!!

  29. Robert S says:

    OMG, thank you so much! This was beyond a great boon! ♥♥♥

  30. Jim Garner says:

    Great job!
    I am wondering if you can help me with a project that seems to be headed in a similar direction as your script.

    I am having folks enter notes throughout the day on places. Each place has it’s own ID number. Multiple Note entries are made on each ID number and they show up in the Form Responses sheet.

    I want to have a script like yours, but triggered for any new entry, to ADD the new note to a GOOGLE DOC in a folder for that ID.

    This means for each ID there is a Google Shared Folder, and in that folder is a Google Doc that has a chronological list of the Notes made for that place.

    This is a little different than what you have done. More involved too, but I hope you can help me or at least hold my hand while I get through it.

    Thanx for sharing your work here!

    Jim

    • James Bowles James Bowles says:

      Hi Jim,
      It sounds like you need an onSubmission hook from Google Forms and then you can call my script to run. You will need to adapt it to use Google Forms instead of Sheets. I haven’t looked into that API much, but I imagine it can be done.

  31. Tiona says:

    Thanks for this resource! I have used your instructions many times with success. However, today when I tried to run the script I keep getting an error message: Cannot call Browser.inputBox() from this context. (line 3, file “Code”)

    I’m not sure what this means – do you know what I might be doing wrong?

    • James Bowles James Bowles says:

      Hi Tiona,
      I suggest using the Save As Doc Add-on now available in the Add-ons Menu in Google Sheets. Simply install it and it should run without issue. Glad you’re enjoying it!

  32. Beth says:

    I’m so glad I found this. I tried it and it works great! The only issue is that when an additional form is submitted, the document isn’t automatically updated. I have it embedded in a website and it isn’t updated their either. I did select ‘automatically republish when changes are made’ in the Google Doc publish settings.

    Is it designed to update automatically and if not is there something I can do to work this out?
    Thanks so much!

  33. Thamara says:

    Hi,

    So I am following the instruction with your Add-on and I guess I am missing something. Save as is where? Google sheets saves as we type and does not offer the “Save as” feature. Help!

Leave a Comment