Copy link to clipboard
Copied
Good morning,
I'm using CSV data in InDesign CC to populate address blocks for postcard mailings. After I import my flat CSV, I need a way to select a field and ask InDesign "What is the longest string in this column of the CSV"? If I could do this, I could catch errors before I export my final PDF.
We used to use FusionPro before that got too expensive, which had this feature front and center in the interface. I just need to make sure that whoever is entering data into the address columns of the Excel file didn't fall asleep on their keyboard and give me an address that looks like:
"123 Main St. AFIH:LGSDH:LKJSGD:LFJA"PUOGFBASDN:ASKLDA":LKJFA"
Thanks!
Okay, here's what I did:
Copy link to clipboard
Copied
Anyone?
Copy link to clipboard
Copied
Hi Mark,
without using a script you could try the following:
Place the text and convert it to a table. Set your cell insets to zero. Format the text to your needs later in the merged document. Set the height of all cells to a value so that one line of text will not overflow a cell. Check overflow.
If cells overflow change the width of all columns until there is no overflow.
Now change the width of a particular table column until there is overflow. Do this using reasonable steps.
By using the Story Editor Window see what cell overflows. Now you indicated the longest text.
Regards,
Uwe
Copy link to clipboard
Copied
Thanks Laubender!
Copy link to clipboard
Copied
Hi,
Could you just show before/after screenshots?
Best,
Michel [FRIdNGE]
Copy link to clipboard
Copied
I'll do my best Michel. Here goes:
Copy link to clipboard
Copied
Could you show the invisible chars? ...
Copy link to clipboard
Copied
I appreciate the help, but I'm not sure of what you're asking. As far as I know, there aren't any invisible characters. See image:
Copy link to clipboard
Copied
The “blue chars”! ...
Copy link to clipboard
Copied
Oh - I see. Okay:
Copy link to clipboard
Copied
So ... could we suppose you just want and need to detect a “second line or more” in a para?
Copy link to clipboard
Copied
That sounds like it would help.
Copy link to clipboard
Copied
So ... you just (and simply) need to include a “nested line style” in your para style (I suppose you use a same one).
Build the associated char style as an “red underlining” and you will just need to play a simple find/replace as: Find this char style!
Best,
Michel
Copy link to clipboard
Copied
Thank you for your help Michel. I haven't used Paragraph Styles or nested Character Styles in a while because we rarely design or print anything more than postcards, flyers, and short newsletters. It's something that I'll have to research more about.
Copy link to clipboard
Copied
This is something I wouldn't check in InDesign, but in the Database beforehand. If you can put the database in Excel, use the solution that can be found on an Excel forum:
https://www.extendoffice.com/documents/excel/1692-excel-find-longest-string.html
There's also the ability to "copyfit" the text using GREP styles once you know the length of the longest line:
Episode 3: Using GREP styles to fit text into a text frame in InDesign - YouTube
Copy link to clipboard
Copied
Thanks Colin, that was basically what I came up with too. I figured it was easier to check the associated CSV.
What Michel wrote made me think: What I was *really* looking for was for when the people entering data pressed Alt-Enter or whatever they do on the software that they're using, throwing a hard CR-LF in their data and screwing up my output. Finding the longest string was one way to figure this out, but I found a better way.
I ended up copying/modifying a VBA script for Excel that finds and removes any of these breaks. So, now I just run the macro on all of our CSV files. It only takes a second or two and it works well enough. Maybe not the most elegant solution there is, but it's good enough for government work.
If I think of it I'll post the script here tomorrow when I'm at work just in case anyone happens by this thread while searching. I'll also take a look at those links you posted. Thanks again sir!
Copy link to clipboard
Copied
Okay, here's what I did:
Selection.WrapText = False 'Removing Wrap Text
Selection.Replace What:=Chr(10), Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
13. Close VBA.
14. Open a test file and run the macro.