Copy link to clipboard
Copied
Ok, so I have modified the script found here and it is working correctly.
My script:
//Front Subheader
var myDoc = app.activeDocument
//var myCell = app.activeDocument.textFrames.everyItem().tables.everyItem().cells.everyItem().getElement s()
app.findTextPreferences = app.changeTextPreferences = null
app.findTextPreferences.findWhat = "FRONT"
var myFound = myDoc.findText()
for(i=0; i<myFound.length; i++)
{
if(myFound.parent.constructor.name == "Cell")
{
myFound.parent.appliedCellStyle = "SUBHEADER Cell Style"
var overrides = myFound.clearOverrides()
}
}
I have two issues however:
1. I want the cell style to apply to the whole row not just the parent cell. I tried changing .parent.constructor.name == "Cell" to .parent.constructor.name == "Row" but that did not work.
2. I want my cell style to be in a group "GENERAL Table Cell Style" and if I put it in there I get an error "46602: A style by that name cannot be found". What would be the separator for the group to the cell style?
Thanks in advance!
Try this,
...var myDoc = app.activeDocument
app.findTextPreferences = app.changeTextPreferences = null
app.findTextPreferences.findWhat = "FRONT"
var myFound = myDoc.findText()
for(i=0; i<myFound.length; i++)
{
if(myFound.parent.constructor.name == "Cell")
{
var parentRowCells = myFound.parent.parentRow.cells;
for(var j=0;j<parentRowCells.length;j++)
{
parentRowCells
.appliedCellStyle = myDoc.cellStyleG
Copy link to clipboard
Copied
Try this,
var myDoc = app.activeDocument
app.findTextPreferences = app.changeTextPreferences = null
app.findTextPreferences.findWhat = "FRONT"
var myFound = myDoc.findText()
for(i=0; i<myFound.length; i++)
{
if(myFound.parent.constructor.name == "Cell")
{
var parentRowCells = myFound.parent.parentRow.cells;
for(var j=0;j<parentRowCells.length;j++)
{
parentRowCells
.appliedCellStyle = myDoc.cellStyleGroups.item("GENERAL Table Cell Style").cellStyles.item("SUBHEADER Cell Style"); }
var overrides = myFound.clearOverrides();
}
}
Regards,
Chinna
Copy link to clipboard
Copied
Thanks Chinna that works perfectly.
Is there any way to search for a cell that contains only the word "FRONT" and not cells that contain the word FRONT with other text around it for example FRONT TYRE. At the moment the script is finding these cells too.
Thank you!
Copy link to clipboard
Copied
Hi,
Pour le Mots seul FRONT,
app.findGrepPreferences = app.changeGrepPreferences = null
app.findGrepPreferences.findWhat = "^FRONT$"
var myFound = myDoc.findGrep()
A+
Liphou