Data Merging – Part 2
Last week I began a series on using InDesign's powerful Data Merge feature. After describing what Data Merge can do, I described the data-source files it can use. In Part 2, I'll show how to create the target document?the InDesign document into which the data will flow?and how to link the data to the document, and preview the results.
First, I'll created the reminder card layout for our imaginary veterinary hospital. This card was created at its printed trim size, and contained the boilerplate information that doesn't change (for example, the logo and the text of the card), and data-field placeholders. While creating the card I placed "XX" wherever the text data will be inserted. To create a frame for the pet image, I simply made a placeholder graphic frame with the Rectangle Frame tool.
Next, I selected the data source. To do this, I opened the Data Merge palette (Window > Automation > Data Merge). When first opened, the palette shows the basic instructions for how to use it. I chose Select Data Source from the palette menu, and selected the data-source file we created in Part 1.
The palette should be populated with data-field names that match the column heads (top row) of the source file. Sometimes, you may get an error message, "The data source has one or more empty field names...." This indicates your data source may have extra columns which are empty; those must be removed before Data Merge can use them. This can easily happen if you're using Microsoft Word as a text editor, where tab characters aren't always visible. Go back into your text editor, or Microsoft Excel, to delete them as necessary.
Next, I moved the data-field names into the layout template. You can either click an insertion point in your text frame (I highlighted my XX placeholders) and double-click the data-field name, or drag and drop the data-field name into place. The data fields will appear in the text surrounded by double angle brackets.
For text, you can use all of InDesign's character, paragraph, or frame attributes to format them, including paragraph, character, and object styles. As you can see in the card, the data-field names don't have to be in any particular order, and can be repeated if necessary. Add commas, spaces, or any formatting you need.
When you want to link the graphic image, just drag the graphic field name from the palette onto the placeholder graphic frame, and its name should appear.
Handling Variable Images. Handling variable images requires a little more preparation: If you remember from Part 1 there was one field which was for "pet_image". In order to indicate to Data Merge that that field is a graphic, its name must be preceded by the "@" character?in this case, "@pet_image".
In each subsequent line, the record must contain the path for InDesign to find the picture. The easy way to handle this is to place the images in the same folder as the data-source file. For my example, there were three images?OrangeCat.jpg, CuteDog.jpg, and LoveBird.jpg?located in the same folder. If you have the graphics in a different location, the field will need the exact path on your computer to the graphic, in a format appropriate for your operating system:
Mac: Macintosh HD:Photos:OrangeCat.jpg
Previewing Your Layout. I then previewed the data by checking Preview at the bottom of the palette, and then used the navigation buttons to move forward and back through the records.
There are a couple of good reasons to do this:
- To look for records that don't fit the frame you have created (like a long name you didn't anticipate). The frame should be large enough to handle the largest element in the formatting you've chosen.
- To look for other errors in the data. These could include extra tabs or commas (this shows up where the right data in the wrong place) or having data capitalized when it's not supposed to be (you didn't check over the data-source file before using it).
In general, it's preferable to fix these kinds of problems in the data-source file, instead of in the InDesign file.
In the next episode, we'll discuss how to merge the target document (the layout) with the data-source file to create a merged document.