• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

306

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

Community Expert , Jan 08, 2021 Jan 08, 2021

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

Votes

Translate

Translate
Community Expert , 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:

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 bl

...

Votes

Translate

Translate
Guide , 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 instan
...

Votes

Translate

Translate
Community Expert ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

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

Votes

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
Community Expert ,
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.

Votes

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
Guide ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

LATEST

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

 

 

Votes

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