How to generate documents from templates automatically
Generate documents from templates automatically: the short answer
Generate documents from templates automatically by filling named fields from one data source, exporting a PDF, checking it, then sending.
To generate documents from templates automatically, you follow five steps for quotes, contracts, letters and order confirmations. Fixed wording lives in one template with named fields. Fields are filled from one data source: a form, the CRM or a spreadsheet row. A script or flow exports a PDF and saves it in a fixed place. A person checks before anything goes out. Prices, dates and legal wording come from the template and the data. AI, if you use it, writes one marked free-text part only, always as a draft.
This is for owners and office leads in Swiss SMEs who write the same kind of document several times a week. Open last month’s quote, save under a new name, swap the customer, change the figures, and the old customer is still in the footer. If you write two contracts a year, skip this article.
- Template
- The file with fixed wording and named fields for everything that changes.
- Placeholder
- A field name in the template filled from the data source.
- Mail merge
- Word or Docs fills many letters from one table without a separate flow.
The five steps from data to a checked PDF
Each step is small. The work is to decide them once and write them down.
One template per document type
A quote, an order confirmation, a letter: one file each. The wording is written once. Everything that changes is a named field: customer, address, project, amounts, date.
One source for the data
The fields come from one place: a web form, the CRM or a spreadsheet row. Not from memory and not from the last document.
Generate and export as PDF
A script or flow copies the template, replaces the fields and exports a PDF. The Word or Docs file stays as the editable original.
File it the same way every time
One folder logic and one name pattern, for example project number, customer, document type, version. Nobody searches Sent Items afterwards.
Check, then send
A person reads the PDF next to the data row and releases it. Only then does the mail go out from the office mailbox, and the send date is written back to the record.
Step 2 is where most projects stall. If the same customer sits in two programs with two spellings, the template prints whichever one it reads. Decide which program leads first: how to stop double data entry walks through that decision.
The check in step 5 takes a minute: amounts, address and salutation, attachments, the free-text part. It is why a wrong number does not reach a customer.
Fill a Word template automatically: mail merge, Power Automate, Google Docs
For a few documents a week, the mail merge you already have is often enough. A quote that needs a different fee table each time usually needs a flow on top.
In Word, a mail merge fills letters from an Excel table. Microsoft’s help page says the column names must match the field names, and that the merge document stays connected to its data source (Microsoft Support). That suits batches of letters, less a quote whose fee table has a different number of rows each time.
In Microsoft 365, Power Automate has a Word Online (Business) connector with the actions «Populate a Microsoft Word template» and «Convert Word Document to PDF» (Microsoft Learn). The same page lists limits that matter for planning: it is a premium connector, rich text and date picker content controls are not supported, and the populate action cannot be used under a conditional-access policy that requires multi-factor authentication.
In Google Workspace, variable chips in Google Docs fill several fields with the same text and export templates with different values. They are available only for eligible work or school accounts, and you fill them by hand (Google Docs Help). For automatic filling you need a script: Apps Script can replace text patterns in a document with replaceText and convert a file to PDF with getAs.
Our own download form uses similar building blocks: a Google Apps Script logs the request in a sheet, fetches a PDF from a private Drive folder and sends it by email via Microsoft Graph. If your business software already produces the quote from its own template, start there.
Where AI helps and where fixed wording is safer
AI helps with the free-text parts that differ every time. Everything with a price, a date or a legal effect should stay fixed template wording.
| Part of the document | Comes from | Why |
|---|---|---|
| Name, address, salutation | Data | Copied, never rewritten |
| Prices, quantities, VAT, totals | Data and rules | A wrong number does more harm than a stiff sentence |
| Terms, payment conditions, clauses | Template, approved once | Legal wording changes only on purpose |
| Introduction, «what you asked us for» | AI draft, marked | Differs each time, a person edits it |
| Summary of an email thread for the file | AI draft | Internal, nobody outside relies on it |
The rule that makes this safe: AI writes into one marked field. It never touches the other fields, and a person reads everything before it leaves.
If that text is drafted from a customer’s email, the email contains personal data. The Federal Data Protection and Information Commissioner (EDÖB) states that the Swiss data protection act applies directly to AI-based data processing (EDÖB: KI und Datenschutz). Do not paste customer emails into a free chatbot account, and ask your data-protection adviser which service fits. This is practical guidance, not legal advice.
Signatures: what Swiss law asks for
Most documents need no signature that the law prescribes. Where one is required, only the qualified electronic signature counts as equal to a handwritten one.
That is the position in Art. 14 para. 2bis of the Code of Obligations, as BAKOM explains it: Swiss contract law follows freedom of form. Where a handwritten signature is required, only a qualified electronic signature under ZertES is treated as equal. Other electronic signatures can be used where no handwritten signature is required. The Swiss accreditation body keeps a list of the providers that may issue qualified certificates (BAKOM).
A quote or an order confirmation usually needs neither. A pasted image of a signature is not a qualified signature: it rests on no certificate and carries no time stamp. Whether a particular contract needs written form is a question for your lawyer, not the template.
Filing: what to keep, and for how long
Keep the PDF that was actually sent, not only the editable original, because the original changes the next time someone edits the template.
Accounting records and vouchers such as invoices must be kept for ten years from the end of the financial year. Electronic storage is allowed if they stay readable and match the underlying transactions (kmu.admin.ch). For quotes and contracts the period depends on the document, so ask your fiduciary or lawyer before you set a deletion rule.
An example: fee quotes at a 12-person planning office
An example, not a client: a planning office with about twelve people. It sends around ten fee quotes a month for renovation projects, and an order confirmation for each one that is accepted.
Today, the project lead opens the last quote, saves under a new name, swaps customer and address, retypes the fee table and exports a PDF. Names differ, and a previous customer sometimes survives in the footer.
The build: one Word template for quotes and one for confirmations. A form writes one row per quote: customer, address, modules from a fixed list, hours or a lump sum. Rates sit in a second sheet the office manager maintains. Terms and payment conditions never change, they stay in the template. One field is free text: how the office understood the project.
When a row is marked «create draft», a flow fills the template, exports the PDF, files it in the project folder under a fixed name and mails it to the project lead, not the customer. An AI service drafts the free text from the project lead’s own notes, marked as a draft. She corrects it and sets the row to «approved». Only then does the flow send the mail from the office mailbox and write the send date back to the row. Reminders can start from that date: see how to follow up on quotes without losing them.
For scale: one document type with one data source matches the guide price of CHF 3’200–4’800. Several types move towards larger packages. The fixed price comes in writing after the Check.
When not to automate documents
Skip it when the volume is low or the wording is not settled.
- Low volume. For a few documents a month, one template file with clear fields and a checklist is enough.
- Unsettled wording. If three versions of your terms circulate, choose one first. Automation would only spread the disagreement.
- Negotiated contracts. Each has its own clauses and often a lawyer’s review. Use the template for the frame, not the content.
- No owner. Every template needs a named person, a date of the last change and an archive of old versions. Otherwise an outdated payment term goes out on every document.
When the Process Check fits
The Process Check fits if someone in your office regularly builds the same kind of document by hand and you want to know what automating it would take. In 30 minutes on Microsoft Teams we look at that one document type: where the data comes from, what changes each time, who checks, and where the PDF goes.
Bring an anonymised or made-up example, no customer data needed. Afterwards you know where to start, whether it pays off, and a price range and rough duration for a build, in a short written summary. The Process Check is free.
Everything else is on the Process Check page.
Written by
Aurum Avis Labs
Builds and ships at Aurum Avis Labs. Writes here about what we learn working with founders and SMEs in the DACH region.
Related Articles
You might also be interested in these articles
How to follow up on quotes without losing them
How to follow up on quotes so they do not die in the inbox. Set a cadence, one owner, and a CRM status. Automation may remind and draft.
How to stop double data entry between two systems
How to find where data is retyped, decide which program owns master data, and pick the simplest connection, from a connector to RPA.
What the Process Check is and what it is not
A free Process Check: a 30-minute call on one workflow, a concrete case and a package size. Not a workshop.