February 11 2007 • 7:02 PM

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.

Card Placeholders

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.

Select data source

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.
Drag fields

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

Windows: c:\Photo\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.

Preview cards

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.

30 Responses discussing this post. Add yours below.

  1. February 12th, 2007 • 3:56 am • Link

    Glad to see this series!
    Any chance your next installment could also include a note on aligning and scaling graphical content within the frames?

  2. February 12th, 2007 • 3:59 am • Link

    One more thing to clarify… InDesign CS2 supports *relative* pathnames on Windows (not tested on Mac). So, the following is valid:
    images\project\my_picture.jpg
    when the ID file is in a folder which contains the ‘images’ folder.

  3. Steve Werner
    February 12th, 2007 • 4:22 am • Link

    Scott,

    I’ll cover the Content Placement Options in the next episode.

    I’ve never needed deeply nested images so I hadn’t tried out relative pathnames. Good suggestion!

  4. Jimmy Alexander
    February 13th, 2007 • 4:19 pm • Link

    This is a very good article because it made me a newbie thrown in at the deep end swim so much easier.

  5. Steve Werner
    February 13th, 2007 • 4:46 pm • Link

    Thanks for the comment, Jimmy. That’s why I wrote it: Data Merge is a fairly deep subject. While the InDesign Help actually contains a wealth of information on the subject, it’s not always presented in a way that’s easy to grasp!

  6. Alfred Langen
    February 13th, 2007 • 8:13 pm • Link

    I love this site!

  7. February 16th, 2007 • 4:06 pm • Link

    [...] We’ll cover how to set up your InDesign document in next week’s blog. [...]

  8. age
    February 16th, 2007 • 9:09 pm • Link

    can a merged file be exported to a multi page pdf for output to a color copier?

  9. teszeract
    February 21st, 2007 • 10:51 pm • Link

    I have looked at merging quite a few times, but I never found a way to accomplish what I need to do. I suspect that it is not possible, but please enlighten me if this is at all do-able.

    I have to brand a newsletter with company logos (about 50 or so) and send out the newsletter in PDF format. The problem is that IDCS creates a single merged document with no option to create multiple pdfs.

    I currently do the job using Quickeys and Acrobat batch actions. But that is going to be complicated for my successor.

  10. February 22nd, 2007 • 1:42 pm • Link

    You can easily split up a multiple page PDF into individual PDFs in Acrobat Pro. Also I’m pretty sure there’s a script that will do from InDesign (sorry can’t put my hands on it right now).

  11. Dave Z
    February 24th, 2007 • 3:46 pm • Link

    I wish this all worked in reverse and I could move data from Indesign back into a database in real time. Ultimately I’d like to extract a document word count to a spreadsheet. Any ideas?

  12. Steve Werner
    February 24th, 2007 • 4:12 pm • Link

    Dave,

    To do that, I imagine that you could do it with scripting. Especially OS-based scripting like AppleScript so the data could be passed to the spreadsheet or database. (But I’m not a scripter. You might ask in the InDesign Scripting User Forum on the Adobe website.)

  13. David Blatner
    February 25th, 2007 • 10:45 pm • Link

    Dave, to move data back into a database, you’d probably want a plug-in, such as DataLinker from teacupsoftware.com.

  14. Duncan A
    March 8th, 2007 • 10:13 am • Link

    Hi,
    I keep getting the message “The data source references one or more unsupported files.The files cannot be previewed or merged” when I go to preview. I’ve tried all image formats (jpg, tif etc) and my path naming is ok. The data source file is working with text. Any thoughts?

  15. Steve Werner
    March 8th, 2007 • 2:01 pm • Link

    When I do testing for problems, I try to change just one thing at a time: Change the path for the images to something very simple, like the Desktop, and see if they work there. Try a different image. Make sure you don’t have permissions issues with the images (on the Mac you’d do a File > Get Info on the images).

  16. Duncan A
    March 8th, 2007 • 2:59 pm • Link

    Hi Steve,
    I’ve worked through this problem as you suggest but still no joy – might be a case of seeing if adobe have anything to say. Cheers

  17. Mark Hardee
    March 9th, 2007 • 3:31 pm • Link

    I haven’t had a chance to check data merge out in CS3, but I hope some logic was added, i.e. rules..
    THAT would be a nice addition…

  18. Steve Werner
    March 9th, 2007 • 3:34 pm • Link

    Well, InDesign CS3 isn’t out yet, so we’ll have to look at the feature list on March 27—announcement day—to see if that’s been changed.

  19. rosa
    March 12th, 2007 • 1:18 pm • Link

    i work on a windows computer. all of the above suggestions don’t work for images. Indesign says the images are missing, all the time.
    anyone any idea why?

  20. March 12th, 2007 • 2:07 pm • Link

    Hi,
    It happen’t to me too, the photos cannot be merged; and the problem was always with the path ( the path was too long).So i tried this : i saved the images in eps format in a folder called “eps” and the path must be \eps\name of the image.eps. You should always state the name of the pictures, and only the folder where the images are saved.
    Like this it works eveytime.

  21. Duncan A
    March 13th, 2007 • 11:28 am • Link

    Hi Guys,
    Just a quick update. My unsupported file issue resolved itself after I added “@” to the start of the image pathname, tried merging unsuccessfully (image not found), removed the @ and tried previewing again (success!!) – don’t ask why this worked, machine glitch I reckon. This is an interesting post on an adobe forum for anyone with problems – http://www.adobeforums.com/cgi-bin/webx/.3bbf6304/0

  22. Gordon Macaraeg
    March 16th, 2007 • 8:08 pm • Link

    I am using IDCS2 on a mac and am having the same image problem. I have tried different paths in different locations. I noticed that in the data merge pallet the field is precceded by a “T” indicating is’t still text Im assuming that is. Splaination Lucy?

  23. March 19th, 2007 • 12:20 am • Link

    [...] It’s been much longer than I expected finishing this three-part tutorial on InDesign’s Data Merge feature, but it’s been a very busy period for me. You’ll find part 1 here, and part 2 here. When I left you, I had created a reminder card layout in InDesign CS2, and created text and graphic frame placeholders. I selected the data source and linked the data fields with the placeholder frames. Finally, I previewed the result. [...]

  24. Mark Easton
    March 27th, 2007 • 11:52 pm • Link

    I initially had some problems with image paths on Windows, but then made sure drive letters were lowercase and I think that made a difference – but now can;t seem to recreate problem so there is something funny there.

  25. itchy
    May 25th, 2007 • 7:43 pm • Link

    InDesign doesn’t have a way to automatically do data merge for facing pages, since it treats the entire spread as a “page.” In other words, if you’d like to have “first header” on the left and “second header” on the right, you’ll get “first header” on both sides if you link it to the same column in the data file.

    A workaround I used is to combine data on the same row in the data file. If you originally had:

    header@pic
    header1 pic1
    header2 pic2

    Combine lines and use the columns:

    left_header
    @left_pic
    right_header
    @right_pic

    Where left_header and @left_pic were row 1 of the original file and right_header and @right_pic were row 2, etc.

    Hope this makes sense. It still might be a pain, but it works. Also, you can leave some column data blank to skip a page if you wish.

  26. Dave
    June 4th, 2007 • 10:27 pm • Link

    I mail merge address a small newsletter, 6 pages (3 sheets doublesided). The address area is on page 6. It works fine, except Indesign keeps incrementing the page numbers as it replicates the newsletter! Is there any way to make page numbering restart for each copy of the newsletter?

  27. October 15th, 2007 • 5:33 pm • Link

    Steve, this is a great explanation of Data Merge — much better than InDesign Help! I’ve also written about InDesign’s Data Merge and assessed other personalization features in the Creative Suite. Check out: http://www.veedeepee.com/2007/10/free_vdp_1.html

  28. December 18th, 2008 • 3:22 am • Link

    Steve,

    Used datamerge for some years now and have a problem come up….. can’t speak with adobe as their own knowledge of datamarge is that limited, I know they will not be able to help.

    1. I have a catalogue of product.
    2. I want indeisgn to plan them 6 up to a page and the template is based on 9up. Therefore, in the database, I insert 3 blank rows per 6 which normally always works fine. I simply delete the 3 blanks and lay the product out design side.

    3. Problem is, the blanks are being skipped.
    No settings are checked to skip blank lines but there obviously seems to be something adrift!

    Even written a complete new database to eliminate the chance of a corrupt file.

    Hope to hear back.

    Regards
    Barry Heath

  29. rdaniel
    September 25th, 2011 • 9:46 am • Link

    hi, i have a problem with the data merge multiple record layout,– background design has bleed– so when creating merged document, it moves or shifts the background image to the left. what’s the best way to do this?

  30. Terra
    December 22nd, 2011 • 2:22 pm • Link

    You are sorta my hero.
    Thanks :)
    Terra

Subscribe to the Discussion

Get the ongoing discussion surrounding "Data Merging – Part 2" delivered to you. Click here to subscribe via RSS.

Leave a Reply

You can use limited HTML tags, such as <em></em> for emphasis/italics and <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

InDesignSecrets reserves the right to edit and/or remove posts and comments.