Skip to main content
Participant
March 10, 2014
Answered

Search for a string in Data Merge, then change the font color

  • March 10, 2014
  • 1 reply
  • 602 views

I'm working on a postcard-style invitation with the addresses on the back. So far, I've finished the invitation and the mail-side template with a Data Merge to a CSV file successfully. Now, as part of my design, I want all of the letter "b"s on the mail-side template (Data Merge) to be yellow. Using JavaScript is this possilbe? This is what I have so far, but something is wrong:

     app.findTextPrefences = NothingEnum.NOTHING as FindTextPreference;

     app.changeTextPrefences = NothingEnum.NOTHING as ChangeTextPreference;

     var myColor:Color = myDocument.colors.add();

     myColor.model = ColorModel.PROCESS;

     myColor.space = ColorSpace.CMYK;

     myColor.colorValue = [0, 0, 100, 16];

     app.findChangeTextOptions.caseSensitive = false;

     app.findChangeTextOptions.includeFootnotes = false;

     app.findChangeTextOptions.includeHiddenLayers = false;

     app.findChangeTextOptions.includeLockedLayersForFind = false;

     app.findChangeTextOptions.includeLockedStoriesForFind = false;

     app.findChangeTextOptions.includeMasterPages = false;

     app.findChangeTextOptions.wholeWord = false;

     app.findTextPrefences.findWhat = "b";

     app.changeTextPrefences.fillColor = myColor;

 

     app.findTextPrefences = NothingEnum.NOTHING as FindTextPreference;

     app.changeTextPrefences = NothingEnum.NOTHING as ChangeTextPreference;

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

After setting preferences you need to call changeText() method, like

myDoc.changeText();

or

myStory.changeText();

But this is a static solution.

You could use a dinamic solution by define a proper characterStyle and take advantage of nestedGrepStyle in style applied to this part of your design.

So each character "b" could be applied with your characterStyle automatically, no need to run a script.

Jarek

1 reply

Jump_Over
Jump_OverCorrect answer
Legend
March 10, 2014

Hi,

After setting preferences you need to call changeText() method, like

myDoc.changeText();

or

myStory.changeText();

But this is a static solution.

You could use a dinamic solution by define a proper characterStyle and take advantage of nestedGrepStyle in style applied to this part of your design.

So each character "b" could be applied with your characterStyle automatically, no need to run a script.

Jarek

brogers7Author
Participant
March 10, 2014

That's just what I was looking for. I'll let you know how it goes. Thank you.

Jump_Over
Legend
March 10, 2014

Hi,

Let me show you how it goes on my side:

Jarek