Script to search table in selected text frame
Hello,
I'm trying to get a script for applying some cell styles based on content to work. Since I'm really new to scripting I can't get this to work as I want to.
The following script does what I want, but it applies to every table in the document. I just want it to apply it on the tables in a selected text frame.
Can anyone help me with this?
Also, is it possible to have more than one word to search for?
var curDoc = app.activeDocument;
var allTables = curDoc.stories.everyItem().tables.everyItem();
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "Vev";
var allFounds = allTables.findText();
app.findTextPreferences = app.changeTextPreferences = null;
for ( var i = 0; i < allFounds.length; i++ ) {
var tableFound = allFounds;
if ( tableFound.length > 0 ) {
for ( var j = 0; j < tableFound.length; j++ ) {
var curFound = tableFound
; var cellsInRow = curFound.parent.parentRow.cells.everyItem();
cellsInRow.appliedCellStyle = curDoc.cellStyles.itemByName( "Reglage line" );
cellsInRow.clearCellStyleOverrides( true );
}
}
}