Create a Form File

The first part of this process is creating a form file in Pages:

Download the Pages Data Merge app and unzip the zip file. macOS puts the file into a folder named PagesDataMergeApp. Define each item of placeholder text to be filled with information from the spreadsheet data file (see below), for example, first name, last name, and address. Click Format > More. On the envelope, highlight each placeholder text, starting with FIRSTNAME. In the top menu, click Format > Advanced > Define as Placeholder Text. In the formatting menu at the bottom, under Script Tag, type a name for this placeholder text field. This example uses FIRSTNAME. Repeat step 4 for each placeholder text item that corresponds to data that will be imported from the spreadsheet: LASTNAME, STREET, CITY, STATE, ZIP. If your spreadsheet has column headers, the headers don’t have to match the placeholder text names (for example, FIRSTNAME and LASTNAME).

Open the Data File in Numbers

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

Assign Placeholder Tags

Next, you’ll tell the app which fields correspond to which bits of data, and where to find the data.

Open Pages Data Merge by double-clicking the unzipped app file named Pages Data Merge. The app is labeled with numbers for each setting you’ll use to create the mail merge. Next to 1 in the app, click the menu and choose Selection Numbers Table. Click Import. The first row is pulled in and displayed. Select the first item imported (in this case, the name James). Next to 2, click the drop-down menu and choose the placeholder tag FIRSTNAME (the first placeholder text item defined). Repeat steps 2 and 3 for each item imported until all items are assigned placeholder tags. For example, select Jones and choose LASTNAME from the drop-down menu. 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 select Pages Document. Other options are: Microsoft Word Document. MS Word Doc (encrypted). PDF Document. PDF Document (encrypted). EPUB. Unformatted Text.

Choose the Export File’s Format and Location

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

The app is labeled with numbers for each setting you’ll use to create the mail merge.

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

Run the Mail Merge

Now that you have assigned placeholder tags from the Pages document to 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. You’re prompted to confirm that you want to perform a data merge using the front Pages document. Click Begin.

The mail merge AppleScript you designed with the app runs. A Pages document is created for each person in the spreadsheet and is populated with 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 is named after the envelope template with a number appended after a dash, for example, mailmerge_envelope-1, mailmerge_envelope-2, and so on.

When the script finishes, a completion dialog box appears. If you click Show, you are taken to the folder in which the individual files are saved.