DEV Community

Cover image for How to mail merge a Word letter from an Excel list and send it only to some people
Hanako H.
Hanako H.

Posted on

How to mail merge a Word letter from an Excel list and send it only to some people

A membership club has 40 members in a spreadsheet and one renewal letter. Typing 40 names into the letter is out of the question, and so is sending it to the 28 members who have already paid. Mail merge solves both: the letter is written once with gaps in it, the spreadsheet fills the gaps, and a filter decides whose rows count. The osFoundry desktop app has this in its Word editor, under the same Mailings tab Word users know, and the steps below use it on a one-page letter and a 40-row .xlsx file. The names and dates are made up for the example.

Connect the spreadsheet

Open the letter in the Word editor and go to Mailings. Click Start Mail Merge and choose Letters, then Select Recipients and Use an Existing List, and pick the spreadsheet. The status bar at the bottom changes to "Recipients: 40".

The Mailings tab with Recipients: 40 in the status bar

Every heading in the first row of the sheet becomes a field that can be used in the letter: First_Name, Last_Name, Plan, Renews and Paid in this file. Spell the headings the way you want to see them later, because they are what you pick from a list in the next step.

Put the fields where the gaps are

The letter has the words NAME, PLAN and DATE where the changing parts go. Double-click one of them to select it, click Insert Merge Field, choose the column and click Insert. The selected word is replaced by the field.

The Insert Merge Field dialog listing the columns of the sheet

A field holds no text of its own, only the name of a column. That is why the same letter can show a different person on every page. Do the same for the other two gaps. If a field lands in the middle of a sentence, check that there is still a space on each side of it.

Preview Results shows the letter filled in from the first row, and the arrows next to it step through the rows. Row 2 is Liam, with an Annual plan renewing on December 21; the plan and the date changed along with the name.

Preview Results showing the letter for the second row

Keep only the people who need it

Before merging, open Edit Recipient List. It shows the sheet as the editor read it, and under Filter and Sort there is a condition to build: Paid, Equal to, No. The line under the conditions keeps count, and here it reads "12 of 40 recipients will be merged."

The Filter and Sort panel with Paid equal to No

Click OK, and the preview now steps through those 12 only. The filter compares the text in the cell, so type the value exactly as the sheet spells it. Sorting is in the same panel, with up to three sort keys, which is useful when the letters will be handed out in an order.

Finish and merge

Click Finish & Merge. The editor builds one new document with a letter per recipient, and asks whether to save the changes to the letter. The merged document opens as Document1 and says Page 1 of 12 in the status bar, one page for each person.

The merged document, page 1 of 12

Reading the saved file back showed 12 different letters, each with its own name, plan and renewal date and no placeholder words left over.

The editor is part of the free osFoundry desktop app, and the files stay on the computer; see how osFoundry works local-first.

Top comments (0)