How to Create a Pages Mail Merge

MacBook Pro Retina

LPETTET/Getty Images

In Pages, Apple's collaborative word processor, creating a mail merge works a bit differently than it does in other word processor software. In fact, there is no built-in function for doing a mail merge in Pages.

However, there is a method for doing a mail merge with Pages using AppleScript, a scripting language in macOS that allows you to create custom task automations. AppleScript very useful, but for most of us who don't know how to use it but still want to do a mail merge, it feels like a nonstarter.

Here we'll make it easy for you. With the help of an app called Pages Data Merge, you will create a customized script designed specifically for performing a mail merge using Pages and Numbers. The app's simple interface is easy to use, so don't let the mention of AppleScript cause you anxiety.

What Is a Mail Merge?

A mail merge is a tool for generating mass mailings, such as form letters or envelopes with addresses. A data file—usually a spreadsheet (in our example, we'll be using Apple's Numbers application)—contains the data that will populate the form. We'll use an envelope created in Apple's Pages application as our form.

Download Pages Data Merge App

As a preliminary step, download the Pages Data Merge app. You'll find the download link at the bottom of the page. The file downloaded is a zip file. When you double-click it, your Mac will unzip it into a folder named PagesDataMergeApp.

Create a Form File in Pages

Screenshot of a mail merge envelope in Pages.

 Rebecca Johnson

We're using a simple envelope template in Pages. The mail merge will let us create separate envelopes addressed to each person from our data file.

Define each of the placeholder text that will be filled with the information from our spreadsheet data file (we'll get to the spreadsheet below), such as the person's first name, last name, and their address.

  1. Click Format in the upper right of the Pages window to open the formatting menu on the right side. Then, click the More tab.
  2. On our envelope, highlight each placeholder text, starting with FIRSTNAME.
  3. In the top menu, click Format > Advanced > Define as Placeholder Text.
  4. In the formatting menu at the bottom, under Script Tag, type in a name for this placeholder text field. In this example we use FIRSTNAME.
  5. Repeat step 4 for each placeholder text item that will correspond to data that will be imported from the spreadsheet: LASTNAME, STREET, CITY, STATE, ZIP.

Open the Data File in Numbers

Data file spreadsheet in Numbers for mail merge

 Rebecca Johnson 

In Numbers, open the spreadsheet with the names and addresses that will populate the placeholder text we defined in step 2. Select all of the cells that have the data you want included in the mail merge. The mail merge app will import only the items you have selected in this step.

If your spreadsheet has column headers, they don't have to match the placeholder text names (e.g., FIRSTNAME, LASTNAME, etc.).

Assign Placeholder Tags

Assigning placeholder tags in Pages Data Merge app

 Rebecca Johnson

Open the the Pages Data Merge app by double-clicking the unzipped app file named Pages Data Merge.

You'll find that the app is helpfully labeled with numbers for each setting you'll use to create the mail merge process.

  1. Next to 1 in the app, click the dropdown menu and choose Selection of Numbers Table. Click Import. The first row will be pulled in and displayed.
  2. Select the first item imported—in this case it is the name James.
  3. Next to 2 in the app, click the dropdown menu and choose the placeholder tag FIRSTNAME (this is the first placeholder text item we defined).
  4. Repeat steps 2 and 3 for each item imported until all items are assigned a placeholder tag. For example, select "Jones" and then choose LASTNAME from the dropdown.

Choose the Export File's Format and Location

File format selection in Pages Data Merge app

  Rebecca Johnson

Next to 3 in the app, choose the file format you would like the mail merge to use for each envelope. In this example, we will select Pages Document. Other options you could select are:

  • Microsoft Word Document
  • MS Word Doc (encrypted)
  • PDF Document
  • PDF Document (encrypted)
  • EPUB
  • Unformatted Text

Next to 4 in the app, click Choose Export Folder and select the location where you want the merged files to be saved.

Number 5 in the app is an optional function that can be used to automatically send individual emails related to the mail merge. We won't be using it in this example.

Run the Mail Merge

Successful mail merge with Pages Data Merge app

  Rebecca Johnson

Now that you have assigned placeholder tags from the Pages document to all of the data items imported from the Numbers data file, you're ready to run the mail merge.

Next to 6 in the app, click Begin to start the mail merge. You will be prompted to confirm that you want to perform a data merge using the front Pages document. Click Begin.

The mail merge AppleScript you've designed with the app will then run. A Pages document will be created for each person in the spreadsheet and be populated with their names and addresses. You'll see each of these pop open and the data added before the script moves on to the next one.

Each file will be named after the envelope template with a number appended after a dash. For example, mailmerge_envelope-1, mailmerge_envelope-2, etc.

When the script is completed, a completion dialog box will appear. If you click Show, you will be taken to the folder you picked to save the individual files.