Skip navigation
Currently Being Moderated

If text exists after merge insert preceding word? Conditional Grep?

May 17, 2013 5:23 PM

Tags: #indesign_cs5 #grep #data_merge #conditional

I'm not sure if this is possible or if it is how to go about it. I have a lot of labels that I am creating using data merge. Certain text fields require a label like this…


Label 1: Merged text data

Label 2: Optional merged text data

Label 3: Optional merged text data

Label 4: Optional merged text data


I have a number of different label styles where the sometimes the label is not used and sometimes it may be a different layout, such as above the merged text. So I have kept the label out of the data and simply hard coded it into the merge template. So I had to create a number of variations for each layout if it has label 1 and 3 but not 2 etc.


I aslo have empty line removal, the hard return will be removed if empty.


So I wonder if it is possible to use Grep to check if text exists for a certain field and conditinally add the styled label text. So I could reduce my template variations. In all I have a bout 5 fields that require this.

  • Currently Being Moderated
    May 18, 2013 4:44 AM   in reply to Angus Hume

    The answer is probably yes, but we'd need more details about the following text.


    On the other hand, it probably would be much simpler to include the text as another field in the data file.

    Mark as:
  • Currently Being Moderated
    May 20, 2013 6:05 AM   in reply to Angus Hume

    ID does have Conditional Text, which may also be another option. Conditonal text is shown or hidden globally, and the same text can, I believe, carry more than one condition.


    But that still leaves trying to test to apply the conditions, or doing it manually (by some sort of code in the data) before the merge. If you know all of the possible combinations of following text I'm sure this can be scripted, but the effort involved is probably more than adding the columns to the spreadsheet.

    Mark as:
  • Currently Being Moderated
    May 21, 2013 4:39 AM   in reply to Angus Hume

    So maybe I'm not really understanding the problem.


    You can use a look-ahead in GREP, perhaps, but I'm not quite sure what you want to look for. You could find blank lines, but it would be difficult to differentiate between different non-blank lines.


    Maybe using unique paragraph styles for each label? GREP can't find text in one style followed by another, but scripting can, I think.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points