Set a paragraph style based on a cell value

New Here ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

Is there any possibility to set a paragraph style to certain cells based on another cell value in another column? Or instead of setting a paragraph style just change the text color.

 

Example what I am looking for (see screenshot):
I want the color of the text in column "D" to change based on the cell value in column "C". All the texts written by John should be green and all texts written by David should be red.

 

A script would make sense as I have thousands of rows. Any ideas?

 

screenshot.JPG



[ attachment inserted as inline image by moderator ]

TOPICS
How to, Scripting, Type

Views

142

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct Answers

Adobe Community Professional , Jan 08, 2021 Jan 08, 2021
Certainly doable with a script. You can look at this thread for inspiration. 

Likes

translate

Translate

Translate
Most Valuable Participant , Jan 08, 2021 Jan 08, 2021
Here is a non-script workaround with a little finagling: First, column D will be replaced with a merged column of C and D. The reason to do this merge is to create an indicator, the indicator can be David and John, or D and J, or some specific indicator. Replace column Create 3 character styles: blank, red, green Create a paragraph grep style with the following: Note: This is one paragraph style that will change copy based on the indicators of D and J. You would change the character style of bl...

Likes

translate

Translate

Translate
Advocate , Jan 08, 2021 Jan 08, 2021
Dirtly and simplistically done, just calling your para styles "John" and "David"! …   /* _FRIdNGE-0685_ApplyParaStyleToNextCell.jsx Script written by FRIdNGE, Michel Allio [08/12/2020] */ var myNames = ["John", "David"]; for ( var n = 0; n < myNames.length ; n++ ) { app.findGrepPreferences = null; app.findGrepPreferences.findWhat = "^" + myNames[n] + "$"; myFound = app.activeDocument.findGrep(); for ( var f = 0; f < myFound.length ; f++ ) if ( myFound[f].parent instanc...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

Certainly doable with a script. You can look at this thread for inspiration. 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

Here is a non-script workaround with a little finagling:

First, column D will be replaced with a merged column of C and D. The reason to do this merge is to create an indicator, the indicator can be David and John, or D and J, or some specific indicator.

Replace column

Create 3 character styles: blank, red, green

Create a paragraph grep style with the following:

grep.jpg

Note: This is one paragraph style that will change copy based on the indicators of D and J. You would change the character style of blank to 0 pt to make it invisible.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

Dirtly and simplistically done, just calling your para styles "John" and "David"! …  😉

 

/*
    _FRIdNGE-0685_ApplyParaStyleToNextCell.jsx
    Script written by FRIdNGE, Michel Allio [08/12/2020]
*/

var myNames = ["John", "David"];
for ( var n = 0; n < myNames.length ; n++ ) {
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^" + myNames[n] + "$";
    myFound =  app.activeDocument.findGrep();
    for ( var f = 0; f < myFound.length ; f++ ) if ( myFound[f].parent instanceof Cell ) if ( myFound[f].parent.parent.cells[myFound[f].parent.index+1] && myFound[f].parent.parentRow == myFound[f].parent.parent.cells[myFound[f].parent.index+1].parentRow ) myFound[f].parent.parent.cells[myFound[f].parent.index+1].texts[0].appliedParagraphStyle = myNames[n];
}

 

(^/)  The Jedi

 

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines