Reply To: How to Change table cell based on a textbox value, per page?

#92903
Anonymous
Inactive

here is my script:

var myDoc = app.activeDocument;
var pagesLength = myDoc.pages.length;
// Loop through all pages…
for ( var i = 0; i < pagesLength; i++ ) {
var myLabel = “topHeader”, // change to label
myTextFrames =myDoc.textFrames.everyItem().getElements().slice(0),
l = myTextFrames.length,
myVariable

while (l–) {
if (myTextFrames[l].label != myLabel) continue;
myVariable = myTextFrames[l].contents;
break; // presuming there’s only one “Foo” labeled frame on the page
// Otherwise you’ll nead an array
}

app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = myVariable;
var myFound = myDoc.findText()

for(i=0; i<myFound.length; i++)
{
if(myFound[i].parent.constructor.name == “Cell”)
{

myFound[i].parent.appliedCellStyle = “Yellow”
// var overrides = myFound[i].clearOverrides() //this is the new line added in this content

}
}
}

This article was last modified on March 16, 2017

Comments (0)

Loading comments...