is now part of CreativePro.com!

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

73

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:

Inlineflow1

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:

Inlineflow3

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:

Inlineflow4

Inlineflow5

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 is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Quentin says:

    Oh wow.

  • Loic says:

    Thanks a lot David ;)

  • Loic says:

    BTW, it also works with regular texts without anchors?

  • @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):

  • PBPDesigns says:

    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!!!

  • 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!

  • Frances says:

    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!!!!

  • Peter Spier says:

    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.

  • Loic says:

    @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.

  • Claudio Marconato says:

    This script is very useful! Thanks Loic!

  • Bigjim says:

    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?

  • That is really impressive, I must say! A very elegant solution!

  • Charles says:

    How do we load scripts to In-Design?

  • Charles says:

    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.

  • @Charles: Here’s how to install scripts: https://creativepro.com/how-to-install-scripts-in-indesign.php

    I’m not clear on the second point… are you using the script, or just Data Merge? What you’re describing sounds like what data merge normally does.

    • Charles says:

      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.

      Thanks!

      • Turbocator says:

        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.

      • Turbocator says:

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

  • Charles says:

    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?

  • Charles says:

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

  • Charles says:

    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.

    CO

  • Charles says:

    David – I took the time to read about you and your history—IMPRESSIVE.

  • Lynn says:

    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.

  • Kelly says:

    THIS. IS. AWESOME.

    Thank you so much – you’ve changed my life forever!!!

  • Sabrina says:

    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 :-)

  • Brian says:

    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

    • @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.

    • Lynn says:

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

  • Brian says:

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

  • Rich says:

    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?

  • Steven says:

    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.

  • Rebecca says:

    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.

  • Steven says:

    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.

    https://ajarproductions.com/blog/2008/11/28/merge-textframes-extension-for-adobe-indesign/

    I really wish they would update InLine Merge, though.

  • Gary Stolz says:

    Thank you Loïc for creating this awesome script, and to you David for giving it this signal boost.

    This is a case of not knowing I needed something until I needed it. The script, with some hand-editing at the end, helped me save a full 50% of the client’s original page count!

  • DC says:

    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.

  • Ashley says:

    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!

    • Ashley Linares says:

      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!

  • Anna says:

    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!!!

  • Linda says:

    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?

    • Linda: I can run this in InDesign CC with no problem. Are you selecting the big text frame with the Selection (black arrow) tool?

      • Linda says:

        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!

  • Coral says:

    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:

    Business
    City
    Phone
    Web
    Icon: 1, 2, 3, 4

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

  • Megan says:

    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?

    Thanks!

    Megan

    • 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.

  • Jandos says:

    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.

  • Josh Seymour says:

    I keep getting text anchors inserted for every empty field. How do I get rid of this?

  • Greg says:

    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.

  • Neil says:

    Great script – is there any way it can deal with blank fields (i.e. not including them as the data merge panel does?

  • Zach says:

    This script no longer works for me. I keep getting the following error message:
    “162>>Cannot create merged document because no placeholders are present. Please add items from the Data Merge panel to the document pages and try again.”
    Yet the placeholders are there, I can click Preview in the Data Merge panel to see the data is coming through.
    Does anyone else have this problem? I’m on most recent cc.

    • JAMager says:

      I am having the same problem; quite suddenly and after years of use! It works in some documents, but not others–although they are set up and run the same and the .csv sources are correct and work in other documents. I have not yet been able to pinpoint anything in common between the runs that fail and the runs that succeed.

      Is anyone else who has updated to InD 2017 having this issue? Has anyone discovered the cause/solution?

      Thanks!

  • Riccardo Riguzzi says:

    I don’t understand how to set the vertical and horizontal space =(
    I create some text and images fields and I put the datamerge in them, group everything and than anchor it to a text frame, but when I use the script it asks to use a regular space or a carriage return as separator and everything overlaps…
    What am I doing wrong?

    • It may have to do with the leading you have set, or other spacing. It’s hard to know what is going on with your specific situation. I usually make sure I’m using paragraph styles and object styles (applied to anchored objects) so that I can adjust spacing based on leading or text wrap or other things (by changing the style definitions later).

      • Riccardo Riguzzi says:

        It was a lot easier and I figures it out just after my questione :)
        I did not set the anchored object “in line”!!!
        Now everything’s working perfectly

  • Kin says:

    Doesn’t seem to work in Indesign CC 2018. There is no text frame that contains all the elements as all the elements are separate. If I try to run the script on one instancem “please select a non anchored text frame” is the error I get.

  • is there a way to edit once you have already run and organized your data? like for instance i am creating a catalog for my eCommerce website, i used this script to make like a thousand products flow in i took a long time organizing them all and then i realized forgot to include shipping price. i added this to my excel file but now i am not sure where to go from here

  • Vanessa says:

    Wooh, it’s wonderful… ANd Really helpful !
    Is it posssible to conserve the link with the dataz base ? If i’m adding something in the data base I can’t actualise once I’ve used the script. However, is it possible to delet the empty lines at the merge ?
    Thank you for your help, and for this amazing script again !!
    Vanessa

  • Wendy Schneider says:

    Please tell me this still works in InDesign 2021!

    • David Blatner says:

      I just tried it in 2020 and it worked… should be good in 2021. I did have a weird error: when I run the script it says “no special data merge characters found” but when I told it to go ahead anyway, it worked.

  • Geoffrey West says:

    How can I get this script? The link doesn’t work anymore! Ack! Help!

  • yearbook cofo says:

    When I run the script, I get a notification that says, “The script cannot run. please select a non anchored text frame and run again.” The text frame are non anchored, so I’m not sure why it isn’t working.

  • Milo says:

    Does anyone know where I can get the software? The download link seems to be outdated :(

  • Joe says:

    David, the script works as advertised. I have some follow-up questions once the steps have been done…

    1. I am adding a large text box in the center of my project. This is so I can give it a title. Once I add this, the “grid” becomes jumbled on the right side. The columns are not centered per each row.

    2. I also want to figure out how to add a little more spacing in between each grouped text/image object set.

    Any direction on these two questions would be wonderful.

    • David Blatner says:

      You can control the wrap around the text box using the Text Wrap panel. You may need to adjust the various options in the panel to get the wrap correct.

      As for spacing: the best option is to apply an object style to the example object before you merge everything together. That way you can control the spacing by editing the paragraph style of the text and the object style settings.

  • >