Skip to main content
SteveP-Integra
Known Participant
September 30, 2015
Answered

Find/Change cell style with GREP

  • September 30, 2015
  • 1 reply
  • 1074 views

Hi All, (my first post here)

I found a handy script on this forum to find/change cell styles in a table. I adapted the script using Peter Kahrel's ebook for use with a GREP query.

I've linked a spreadsheet in InDesign CC 2014 that I want to highlight the cell of new products that contain the value .

When I run the script below I am getting random results.

var myDoc = app.activeDocument

app.findGrepPreferences = app.changeGrepPreferences = null

app.findGrepPreferences.findWhat = "\[\u\]"

var myFound = myDoc.findGrep()

for(i=0; i<myFound.length; i++)

{

    if(myFound.parent.constructor.name == "Cell")

    {

  

   myFound.parent.appliedCellStyle = "New_Product_Cell"

    }

}

This topic has been closed for replies.
Correct answer Jump_Over

Modify script as I wrote above.

Otherwise your find formula is just "" ==> so InDisign found is --> Direct Manufacturer Name


Jarek

1 reply

Jump_Over
Legend
September 30, 2015

SteveP-Integra napisał(-a):

...

When I run the script below I am getting random results.

...

Hi,

It says nothing. Describe results you get.

Regardless of above you have to remember about "escaping" wild_characters

line 3:

app.findGrepPreferences.findWhat = "\\[\\u\\]";

Jarek

SteveP-Integra
Known Participant
September 30, 2015

Thanks for the reply.

I search the table in InDesign UI using the GREP query \[\u\] it returns the correct results and finds .

eg. HW1971

When I run the script it changes fields that do not contain brackets or uppercase letters (see example).

Jump_Over
Jump_OverCorrect answer
Legend
September 30, 2015

Modify script as I wrote above.

Otherwise your find formula is just "" ==> so InDisign found is --> Direct Manufacturer Name


Jarek