Episode 16: Data Merging into the same Text Frame
Articles Blog

Episode 16: Data Merging into the same Text Frame

November 11, 2019

From time to time, I hear the question, how
do I get Data Merge to put the next records in the same text frame in a multiple record
Data Merge? Using nothing but Data Merge, there’s no way
to do this in one step, and here’s why. In this example, I want to prepare a catalogue
based on the results that occur in this text frame, and I’d like the results to also appear
the same text frame once it’s merged. It’s important to point out that when I look
at my records, there is not a record there that says “next record”, nor when I go to
my flyout menu is there an option that says “next record”, or in the Content Placement
Options… …and that’s disappointing. So it’s a sad day when I can say that Microsoft
Word has features that Adobe InDesign doesn’t. And today is one of those days. Word has a next record option for its Mail
Merge feature, so let’s take a look at that. Going to use an existing list… …it also lets me import Excel files… …I’m not formatting this mainly because
of time, but if you wanted to you could apply paragraph and character styles just like you
could in Adobe InDesign. What I want to demonstrate is here is this
item – next record. By itself, it doesn’t do a lot, it doesn’t
put anything there. However, if I copy this, and I then paste that… …and I preview the results… …you’ll see as I go down the page…. …more of the results are coming in. I also have a lot of other options that I
can select, such as If…then else. Again, something else Adobe InDesign’s Data
Merge doesn’t have and I would like it to. Anyway, let’s merge this. So, that’s now merged it and what I can do
is I can just delete the page breaks as I go, that’s fine. In fact, one solution –
and I can’t believe I’m even suggesting this is to perform the Mail Merge in Word,
Save it and then import it into Adobe InDesign, adjusting the formatting through the import
dialog box. Back to the original problem. If I go to the Data Merge palette, and I select
“Create Merged Document”, there’s nowhere in this dialog box to instruct the next record
to insert into the same text frame. If I choose Multiple Records, turn my preview
multiple record layout on, I can see that the next record is in a separate text frame,
and that’s not what I want. I want it to be in the same text frame. For now, I have no choice, so I’m going to
merge this anyway. So this is my merged file, and I have threaded
text and invisibles on, and when I highlight everything on the page, you can see the text
isn’t threaded from one text frame to another. I can do this manually, but if I have a very
long document, threading one… …to the other… …to the other… …did that even thread? No… …you get the idea, it’s going to take me ages,
I don’t want to do that. Instead, there are some scripts that can help. Theunis de Jong, better known as Jongware,
has made a script where – if I select everything on the page, I can run his script and it will
automatically thread it. It works on one page at a time, so on this
document I have to do this ten times. So, that’s a good script but it’s not perfect. Justin Pudney of AJAR Productions has a script
called Merge Textframes. This allows me to select all pages, sort it from the top, insert a separator, in this case it’s going
to be a hard return and I want the resulting text frame to be
“merged content”. Click OK. So I run that script, and that appears to
have worked, it’s done a very good job, and it’s also put it one text frame, and removed
all of the breaks. Unfortunately, it’s only done it per page,
I still have to thread this page to the next page, and so on. It’s a lot better than the option I had before,
but it’s still a lot of work. There is a script that trumps all two of those,
and that’s this plug-in from Rorohiko, called text-stitch. I’ve already configured this ahead of time,
so I’m going to go “auto-stitch”. It asks me “thread any unthreaded text frames
throughout the whole document?” Yes… OK. And voila, it’s threaded every text frame, including over pages. So what I can now do is I can bin that, I can remove… these text frames, make that frame fit to margins,
add a new page, and then flow the document automatically. But, that’s the long way of doing things. If I want to achieve exactly the same result
without all of the merging and threading, then perhaps consider this script
“inlinemerge” from Ozalto. With the field codes still visible, select
the text frame and run the script. In the dialog box that appears, I want a Carriage
Return between each record, and click Run. And it’s finished! Once again, fit my frame to margins, and flow the document on. Just as an aside, if you’re wondering where
these options have come from, they’re not there by default, they’re added using a startup
script, I’ll leave a link in the description. Trouble with all of these methods is that
if wholesale changes are made to the data, the entire procedure has to be run again… either that or look forward
to a lot of manual labour. Now there is another option but only for those
with plenty of patience, and that is XML. So here I have a document that I have already
an XML input with the appropriate tags, but the data that came from Excel has been saved
as a text file, and on a Macintosh, Microsoft Excel doesn’t have
an XML export option. Luckily, a script from Roland Dreger can convert
my text file to XML. I navigate to the data, Give it a name, Make sure it’s formatted,
Now I have no choice but to view the XML structure and that’s actually a good thing, and that’s
what I want, so I can save the XML file. I’m going to open up the XML file and do a
couple of things to it. First thing I’m going to do is remove the spaces that
appear at the front, and I’m going to change this to UTF-16. And I can save and close. From my structure, and to get to this menu,
go to your view, go structure, and it would typically say “show structure”. In this case, it’s already shown. I also have my tag markers shown,
and tagged frames are also shown here as well. I click on the word “data”, and I go Import XML. Go to my XML document, I’m satisfied with all of those options. So it shows me the first record. I could put in the fourth record, it will
format it… If I want to do the whole document, I drag
the data frame over… once again, fit frame to margins… …and flow it on. If the XML needs to be replaced, it can be
replaced very easily. Just go insert XML, and go append content. But this is just a brief look at XML. However, it can be a very powerful tool. Definitely check out Jim Maivald’s course
on Linkedin Learning if you want to know more. Of course, these are only free solutions made
possible by scripters who have chosen to make these scripts available in the public domain. There are more customized plug-ins better
suited to this task, and they are available from the following manufacturers. Unlike other solutions shown in this video,
these solutions are not free. Nor is any support provided by Adobe since
the solutions are made by a third party, so make sure that the option chosen is easy to
use, and has support that is easy to access if it’s required. That’s it for another video. If you got something out of this video, show
me by hitting the like button, and subscribe for more great videos. Check out colecandoo or indesignsecrets for
the latest articles, or tweet me @colecandoo. Until next time, I’ll see you later.

Only registered users can comment.

  1. ajars merge script is not working properly for me. it inserts the "r" into my text and the order gets lost. EDIT: got it! i had turned on the option that fits the textframe to the text, thats why it squeezed all the letters 😀 thanks for the tut. scripts are allowing me to enjoy life some more haha

Leave a Reply

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