Back to Google Docs in Excel
SheetXAI logo
Google Docs logo
Google Docs · Excel Guide

Mail-Merge a Google Doc Template From a Google Sheet

2026-05-14
5 min read

The Scenario

You're a legal coordinator at a consulting firm and the partnership agreement just got revised — new liability cap, updated notice period, two new clauses. The firm has sent 25 active client contracts over the past year, all based on the same Google Doc template, all with slightly different client-specific values. Your partner just forwarded you an Excel sheet with all 25 doc IDs in column A, client names in column B, contract values in column C, and start dates in column D. He wants updated, fresh copies sent by Thursday.

The bad version:

  • Open the template. Make a copy. Go to Edit > Find & Replace. Replace "{{client_name}}" with "Thornton Industries." Replace "{{contract_value}}" with "$84,000." Replace "{{start_date}}" with "March 1, 2026." Check that none of the placeholders were missed. Save. Copy the URL. Paste it into column E of the workbook.
  • Repeat that sequence 24 more times without making a single substitution error.
  • Notice on doc 18 that you accidentally replaced "{{start_date}}" with "$84,000" because your clipboard had the wrong value. Go back in and fix it. Wonder if you made the same mistake anywhere else.

Twenty-five contracts is the kind of job that takes a junior paralegal a half-day and still needs a proofreading pass. Your time is not for find-and-replace.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent inside your Excel workbook. It reads your data and talks to Google Docs directly — it can copy a template, perform the substitutions, and write the resulting doc URLs back into the workbook for you.

Open the SheetXAI sidebar and paste this prompt:

For each row in my Excel sheet, duplicate the Google Doc template named "Contract_Template" and replace the client_name, contract_value, and start_date placeholder tokens with values from columns B, C, and D. Name each new doc "[Client Name] Contract" and write the URL to column E.

What You Get

  • 25 new Google Docs created from the template, each named after the client in column B.
  • All three placeholder tokens replaced with the row-specific values from columns B, C, and D.
  • Column E populated with the direct URL to each completed contract doc.
  • Any placeholder token that couldn't be matched is flagged in a note rather than left as a raw token in the output.

What If the Data Is Not Quite Ready

Contract values in column C are inconsistently formatted — some as "$84,000," some as "84000," some as "84,000 USD"

Before generating the contract docs, normalize all values in column C to the format "$X,XXX" with no currency suffix. Then copy and fill the Contract_Template for each row using columns B, C, and D. Write each new doc URL to column E.

Some clients have a "Net 45" payment term instead of the default "Net 30" — indicated by "Net 45" in column F

For each row in my Excel workbook, copy the Contract_Template and replace client_name, contract_value, and start_date. If column F says "Net 45," also replace the payment_terms token with "Net 45"; otherwise use "Net 30." Write the URL to column E.

The template lives in a sub-folder in Drive and I only have its doc ID, not its name

Using the Google Doc with ID 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OhWIjq8pQ as the template, copy it once per row in my Excel sheet. Replace client_name with column B, contract_value with column C, and start_date with column D. Save each copy in the same Drive folder as the template and write the URL to column E.

Normalize inconsistent date formats, fix contract value formatting, skip any row marked "Archived," then generate all 25 contracts at once

In my Excel workbook, skip rows where column G says "Archived." Normalize dates in column D to "Month D, YYYY" and contract values in column C to "$X,XXX" format. Copy the Contract_Template for each remaining row, replace all three placeholder tokens, name each doc "[Client Name] Contract," and write the URL to column E.

One prompt handles cleanup and generation — you don't split those into two separate passes.

Try It

Get the 7-day free trial of SheetXAI and open your contract tracking workbook, then ask it to fill and generate all 25 contracts from the template. When you're done, see how bulk text updates across existing docs work, or browse the Google Docs integration hub for more tasks.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more