Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

A script to apply cell style to entire rows containing a specific text

$
0
0

Hi,

 

I am using InDesign CC 2014

 

Does anyone know how to apply a cellstyle based on text contents found in a cell in javascript?

I need to search the document and change cell style in entire row to "cellStyle01" if the text "someText" appear in cell.

 

I've found similar script here in forum which apply table style, but don't know how to change it to apply cell style!

 

var curDoc = app.activeDocument;
var allTables = curDoc.stories.everyItem().tables.everyItem(); 
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "someText";
var allFounds = allTables.findText();
app.findTextPreferences = app.changeTextPreferences = null; 
for ( var i = 0; i < allFounds.length; i++ ) {
var curFound = allFounds[i];
if ( curFound.length == 1 ) {
var curFoundParent = curFound[0].parent; 
// curFoundParent.parent.appliedTableStyle = curDoc.tableStyles.itemByName( "tableStyle" ); 
curFoundParent.parent.appliedCellStyle = curDoc.cellStyles.itemByName("cellStyle01"); 
}
}

 

Thanks!


Viewing all articles
Browse latest Browse all 15932

Trending Articles