Thanks for coming to, the world's #1 resource for all things InDesign!

Data Merge Into Inline Anchored Objects So They Flow in a Story

You know that:

But one thing Data Merge cannot do in InDesign is flow objects (or groups of objects) into a single story! That is why it has never been particularly good for directories. Loic Aigon created a script a while back that helped get around the limitation by combining Data Merge and tables -- so that you could get a single "flowing story" with one long table.

Now Loic is back with something that is perhaps even more cool: A free script that lets you use Data Merge to flow inline, or anchored, objects!

This is much harder to explain than to show, so? here's the original template:


Notice that this is two objects -- a graphic frame and a text frame -- grouped together, then anchored into a large text frame. The frames have been tagged with the Data Merge panel so that the image goes in the top and the name in the bottom. (We have lots of other tutorials here on how to load the data file and tag objects with Data Merge.)

I have installed Loic's script, called InlineMerge.jsxbin (I'll tell you where to get it in a minute), as well as lots of other fun scripts in my Scripts panel:

InDesign Scripts Panel

Now all I need to do is select the larger text frame (the one that contains the inline objects) and double-click the script. The script merges the data into the frames on the page, repeating the inline object inside the story in order to import all the data:


The reason this is so cool is that you can quickly and easily reflow the data! You could delete one of the people on this page and everyone would reflow. Or you could resize the frame, or put an object on the page that has text wrap, and it all reflows:



That, in a word is AWESOME. This is how Data Merge should work now! (Adobe, take note!)

If you like it, see Loic's website here. And you can download the script to try yourself here.

Ultimately, as I've said before, you'll get far more control if you use a third-party plug-in such as InData, but if Data Merge does what you need, then make the most of it!

David Blatner
David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at are among the most watched InDesign training in the world. You can find more about David at
David Blatner

Latest posts by David Blatner (see all)

Related Articles

55 Comments on “Data Merge Into Inline Anchored Objects So They Flow in a Story

  1. @Loic: WHAT?! You never told me that! Wow… I just tried, and it works beautifully!

    Here is “before” (where the text is just loose in a single text frame):

    Here is “after” running the script (the text is repeated over and over again with the proper data):

  2. Woah! Wish I had heard of this about 2 months ago when I had to do an alumni directory. Would have made it MUCH easier!!!

  3. W-O-W! This is effectively the missing “next record” feature that was missing from Data Merge that prevented text directories from being done with Data Merge. Bring on the catalogue work I say!

  4. Oh my. Bang your head against the screen and it will come. Just finished hand importing 200 images Tuesday because of some data merge issues and here it is! Is it okay to use data merge w this script for images while using datalinker for intense data merging?

    And Thank You!!!!

  5. This is perfect timing. I have to run a directory in the next day or so, and I’ll give this a shot. It could save me having to stitch a couple hundred frames together.

  6. @all, thanks a lot for your comments. Much appreciated.

    @Frances, I have no experience using dataLinker so I can’t really say much about your expectations. Best thing is to give it a try I guess.

  7. Cool trick. I only wish I could write such scripts. If you can generate your image file names and other text as an XML-based datastream, you could do the same function by building a sample element group and then importing the XML using the clone function. Text and graphics will also flow automatically through the text frame.

    Don’t you just love the flexibility of InDesign?

  8. Can someone help? I want to take my data and have it flow to certain positions of a page. I’ve view the tutorials. I am confused. when I put the data record on my first page ( not my master) I do not get the new records an a new text box but a whole new page is created.

    Now when I put the info on the master page it flows making the right amount of records….But it is not flowing onto the page with my circular file information. I would have to copy an past the text into my text boxes….

    Not sure what to do.

    • Hey Thanks for the time!

      Second point – I create circulars for grocery stores…I’m sure you ahve seen some sort of circular pitching produce or sales.

      All I want to do is take the Excel info that is given to me and merge it into the text boxes I already created in the layout. Data merge seems to flow the inormation but creates its own text box.

      How can I set it up so that In-Design and Excel understand to take one field of information place it then move to the next field that I have put in a specific place.

      Not sure if this helps or not. I hope it makes sense, I need help to auto mat these grocery circulars.


      • Here’s the trick…

        ~ Set up your document with the boxes linked.
        ~ Format text for the first one, set up style sheets.
        ~ Use the “insert break character->frame break”
        to get to the the second frame, and enter more text.
        ~ Export the text as an InDesign tagged file.
        ~ Open the tagged text file in Word or other app.
        ~ Look closely and you will find where the frame break code is… “”

        You need to get that code into the last position of the text string for each grocery object. This was kind of complicated, but I wanted you to understand the tagging concepts.

        Personally, I always pull Excel files into a FileMaker database where I can do a whole lot more like….

        ~ Exporting the entire file with the ID tags already included.
        ~ Sorting/selecting specific items or subsets.
        ~ Rearranging the data order
        ~ If your Excel data had a “promo level” data field, say L,M,S,P (large/medium/small/priceliner) or something else, you could use conditional If/Then/Else to export the content of the various parts of the circulars complete with the appropriate tags included.

        With a bit of time invested in development, most of the circulars could be built with just a bit of point & click (other than graphics). Don’t know how well this would mesh with the scripting mentioned above.

      • Should have known better. The ID tag for a frame break is ” cNextXChars:Box ” where those spaces are open/close symbols (no quotes).

  9. Sorry it took so long – THANK YOU! I’m going to give it a try. So I put cNextXChars:Box as the last copy in the box?

  10. Gah- frustration….I’m not doing it right. I keep getting the first data field repeating in each box.

  11. I was hoping maybe you could post some screen shots of how the Data source and the Ind-design boxes and text should look? I hope so.

    Thanks in advance.


  12. Hi, this is great! I have managed to flow, in columns, continuous entries of one pic and text underneath using this script. I am now trying to update the flowed information by updating the Excel document and updating the data source file, but it isn’t updating the InDesign document when I choose update Data Source from the Data Merge panel. Do you know why it isnt happening?

    • @Lynn: Unfortunately, the script has no method for updating the data. Remember, the script is doing the merge here, not the Data Merge panel, so the normal data merge features don’t work.

  13. Hey David, you can also do this using the Fuga Tech plugins, plus apply conditional logic to each object (to change sizes, character styles, etc). You’d use the Paste Into action, just be sure to load the data and apply your conditional logic to the object before pasting it into the text frame, since currently it’s tricky to modify an object using the plugins after it’s in there. If you have any questions you can contact me (I’ll try to get a tutorial for how to do this up on our site soon). And yes, I do work for Fuga :-)

  14. This is a great tool. It worked great for me building a double page spread for a newspaper for dental graduates. I am having a problem with it though. I tried to use it for Photo Directory, it did not work. It only put together the first page. It did not put the other 55 together. Any ideas? The only thing I can think of is I need to create the whole 56 page book and put a text box on every pages and link them? Or maybe use master pages? If you can help that would be great. Thanks.


    • @Brian: You could use primary text frames and use Smart Text Flow, or you can just flow the first page and then click on the Out port of the overset text frame (with the selection tool), go to the next page, and Shift-click to place the rest of the story.

    • I have created multiple page documents which automatically adds pages by putting the data fields on the Master pages. Lynn

  15. Thanks for the tips David and Lynn. David, your suggestion worked great. Thank you. Lynn, I will have to give your suggestion a try.

  16. This works brilliantly on my colleagues’ macs but I keep getting an error message, “198>>Object is invalid”. The only diference between their mac and mine is that I installed the new operating system Mavericks. Does anybody know if there are any compatibility issues or if there is any reason why I keep getting this message?

  17. I’m having the same problem as Rich since updating to the new mac OS. I get a complaint that the script does not work in an anchored object, which would not be an accurate observation about the text frame I am using.

  18. I’m trying to do the inline merge and it keeps stalling out. My .csv file is accepted and I get as far as the script asking for the character separator but after that it just spins its wheels. My file is big, 3400 rows. Is that the problems?
    Using InDesign CC
    Any help is appreciated.

  19. It stopped working (after doing a beautiful job) but I found a slightly annoying workaround. I data-merge as a multiple record per page document and then use the free Merge Text Frames script. The script gives you the option to separate the text in frames with a return, but I found it better to make sure your last data field has a return of its own, for speed but especially to maintain stylesheet purity.

    I really wish they would update InLine Merge, though.

  20. Sorry… I am still back on InDesign CS3 and Mac OS 10.5.8 and am getting Error Number 25 and some coding. I am assuming this script is for later versions of InDesign and that is why I am getting the error? Does anyone know where I can get this functionality in a script for CS3? Thanks.

  21. This is amazing! So glad I’ve found your blog and now this helpful tool!

    I do have a question. I have an anchored object and the script runs perfectly. But how can I adjust the spacing between the entries? There is a larger gap than I would like between objects and I’m trying to decrease that. Any tips? Thanks!

    • Sorry – dug around a little bit and, of course, it was a simple fix. The leading!

      One last question, if you still come back to these older posts: is there a way to apply an object style to alternating records to achieve a directory listing where every other listing has a fill color?

      Thanks in advance!

  22. Thank you so much for this! I’m sure I speak for everyone when I say – YOU SAVED OUR BUTTS & made our weeks with this script!
    Bless you sir, and thank you!!!

  23. The script seems to have a bug and I get the same error message, “The script cannot run. Please select a non anchored text frame and run again.” I am using CC and selected the big text frame as well as the small anchored frame. Both result in no merge.
    Does anyone have advice on how to get this to run on CC?

      • Hi David,

        Thank you for responding. I realized this morning of a few mis-steps in my process. I didn’t thread the text frames properly. And second, on the .csv files, the extension was incorrectly set for .ai instead of .jpg.

        After some corrections, it worked!!!

        Thank you for getting back to me and guiding the correct path. Of course, the script is correct :) It was just my human error.

        Have a fantastic day!

  24. Yes! I think this is exactly what I need. I have a directory in a magazine that I design, and some (not all) listings have various icons neat to them. Some have 0 icons, some have up to 4. In the past, I just had a long list in a regular text box flowing from one box to the next and would have to manually add each icon next to the text box. Each time I needed to update the directory, I had to manually move everything around. This issue, I wanted to do a data merge so that at least things could, kind of, update themselves. BUT I was having a problem with listings not flowing with categories, and I still had to manually put all of the icons in the right place. Even when I tried doing an image merge, it was based on a grid. So if the first 3 spots were blank, it looked really weird. Do you know if this can reflow images based on blank spaces? Like, if I have:

    Icon: 1, 2, 3, 4

    But there’s no icon 2 or 3, will it reflow 4 to be directly next to 1?

  25. Question!
    I’m working on a new-person booklet for a client, they have us do it every year. I’m curious, how would I reflow new data into using this plug-in the next time we do a job like this, or similar to this? Is there a way to reformat all the image frames at once, say if they want a stroke around the images?



    • Megan, there is no way to change the data once it is flowed. You would have to reflow it. To reformat all the image frames at once, you would want to apply an object style to the frame before you flow it. Then you can later change the object style definition.

  26. Carol, if it was me, I’d ask the client to provide a unique code for each icon, which they probably are doing anyway (so that you know who get’s which icon). You can format the first one as an anchored object, get it the way you want it, then copy it. Then do a grep search for the text code, replacing with Other>”Clipboard Contents formatted. There are ways to bulletproof this depending on setup if you know GREP, but if you want to keep it simple make sure the codes are not strings of letters that would likely appear naturally elsewhere in the document All caps three letters no vowels would be pretty safe), or you might replace something you don’t want to. Data Merge, and for that matter XML do provide ways to automatically import images, but they require a fair amount of prep work—great if someone else is doing it, I’d rather work in InDesign.

    Megan, I’m not a big user of object styles, but I would definitely use them in this case. I’ve never done this, but I’d bet you can apply an object style on merge and then you’d have global control over the frames—assuming I understand the question.

  27. It is working for me except that it places all of the entries on top of each other. I have tried different wrap settings but am clearly missing something.

Leave a Reply

Your email address will not be published. Required fields are marked *