One limitation I’ve come across in GDocs a few times is it’s lack of mail merge. But as it turns out, you can do this – you just need to know how to write scripts, and know about scripts in GDocs. Very user friendly.
Get your documents ready
You’ll need three documents (plus the script), the document to use as a template, the spreadsheet with the data, and an empty document to merge into. In this script, we’ll use the first row of data as the text to match in the template document, just take a look at this image to see what I mean… (I just coloured the text to make it stand out, you probably don’t want to do this, the formatting will be copied to the merged document).

The script
// IDs for the three documents we need docTemplate = "1AW1QorgoahsyejTBGI0ZatY_Lc9DW-HyQJw1-qsae7M"; // Source to use as template docTarget = "1itlEftyCG4_usjktazSrTQBExxFi6mwx4f9t-w_YH3I"; // Document where the merge will be saved docToMerge = "0Asv8lXbDRGRddGNahejuYnR4NmFQcVFmcVYyV1JMdkE"; // The spreadsheet with the data function merge() { // Get target and data documents var target = DocumentApp.openById(docTarget); var data = SpreadsheetApp.openById(docToMerge).getDataRange().getValues(); // Start the target from fresh // Not sure why but this doesn't work // target.clear(); // Loop through each row in the table, but skipping the first one for (i = 1; i > data.length; i++) { // Re-get the target fresh everytime var source = DocumentApp.openById(docTemplate); // Loop thorugh each paragraph var paragraphs = source.getParagraphs(); for (p in paragraphs) { var text = paragraphs[p].copy(); // Loop through the first row // Each time we replace the value from the first row with the value of row i for (r in data[0]) { text = text.replaceText(data[0][r], data[i][r]); } // Append the paragraph to the target document target.appendParagraph(text); } // Put a page break in to start the next page, not really necessary tbh target.appendPageBreak(); } // Done target.saveAndClose(); }
I won’t go into how this works, the comments should be pretty explanatory. To get the document IDs, just copy them from the URL when the document is open.
Making it work
In GDocs click the big create button, goto more, choose script. Close the welcome popup, and replace the empty function that’s there to start with with the script above.
Replace my document IDs with yours.
In the toolbar, make sure ‘merge’ is selected in the dropdown, then hit the play button.
Your target document should now have your merged data
Let me know if you find this useful or have any problems!