Skip to main content
Participating Frequently
October 21, 2024
Question

Trying to apply GREP styles via data merge but getting inconsistent results

  • October 21, 2024
  • 1 reply
  • 293 views

I'm putting together a set of investor reports, one for each product that our investors have invested in. Each one has a different brand color associated with it. So far data merge has been great for this, but I've had to go in after the merga an manual change accent text and other elements to the correct brand color.

 

I found a video for how to automate this process by

  1. creating a field in my csv for color (lets just call it "Color"), and filling ti with something like {red}, {blue}, {green} etc. 
  2. putting the <<Color>> data merge tag on either side of each instance of accent text,
  3. creating a character style called "invisible" that gives it a color of none and shrinks it to the smallest font size possible
  4. Applying a few GREP styles to the paragraph: Apply invisible character style to any instance of the text {red}, {blue}, or {green}:

\{red\}|\{blue\}|\{green\} etc.

Apply color red to text with {red} on either side of it:

(?<=\{red\})(.*?)(?=\{red\})

Do the same with green, blue, etc

 

I've done the GREP styles with a paragraph style I'm calling "color changinig" and applied it (along with the data merge tags) to about a dozen instances of text among different text boxes in the report. When I hit preview it works for the first instance and none of the others. When it doesn't work, none of the GREP rules are applied- the text that should get the invisible character style isn't, and the colors aren't changing. 

 

It would be simpler if it didn't work at all, but it's working perfectly in exactly one place. I don't see what the difference between the instances of text are. Any ideas how to troubleshoot?

This topic has been closed for replies.

1 reply

JPatGPAuthor
Participating Frequently
October 21, 2024

Figure out where the problem is but not how to solve it: the instances where the pieces of text have character styles applied are the ones that aren't working. If I clear the character style to none, it works great. But it also loses the formatting I wanted which was the point of the character styles in the first place. Is there a way to make this work with gout having to set all the font size, weight, etc via overrides for each instance of text?