Copy link to clipboard
Copied
Hello! I tried to run this script that I found in this thread: https://community.adobe.com/t5/indesign/script-to-find-change-stroke-in-tables/td-p/4315033?page=1
I'm trying to change the border colour, but it keeps returning the error as shown below.
I have no idea what's going on. Could someone please be kind enough to have a look at the script?
Thank you so much
---
myDialog = app.dialogs.add ({name:"Recolor Tables",canCancel:true});
swatchlist = app.activeDocument.swatches.everyItem().name;
with (myDialog)
{
with (dialogColumns.add())
{
with (borderPanels.add())
{
staticTexts.add ({staticLabel:"Find"});
swf = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
tbf = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });
tbfStrk = measurementEditboxes.add({editValue:0.5});
}
with (borderPanels.add())
{
staticTexts.add ({staticLabel:"Replace"});
swr = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
tbr = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });
tbrStrk = measurementEditboxes.add({editValue:0.33});
}
with (borderPanels.add())
{
dostrokes = checkboxControls.add({staticLabel:"Change strokes", checkedState:true});
dofills = checkboxControls.add({staticLabel:"Change fills", checkedState:true});
}
}
}
if (!myDialog.show() || !(dostrokes.checkedState || dofills.checkedState))
{
myDialog.destroy();
exit(0);
}
findtint = tbf.editValue;
findStrk = tbfStrk.editValue;
findswatch = app.activeDocument.swatches.item(swf.selectedIndex);
changetint = tbr.editValue;
changeStrk = tbrStrk.editValue;
changeswatch = app.activeDocument.swatches.item(swr.selectedIndex);
strokes = dostrokes.checkedState;
fills = dofills.checkedState;
fillchanges = 0;
strokechanges = 0;
tb = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
for (t=tb.length-1; t>=0; t--)
{
tab = tb;
for (c=0; c<tab.cells.length; c++)
{
if (fills && tab.cells.fillColor == findswatch && tab.cells.fillTint == findtint)
{
fillchanges++;
tab.cells.properties = {fillColor:changeswatch, fillTint:changetint};
}
if (strokes)
{
s = false;
if (tab.cells.topEdgeStrokeColor == findswatch && tab.cells.topEdgeStrokeTint == findtint && tab.cells.topEdgeStrokeWeight == findStrk)
{
s = true;
tab.cells.properties = {topEdgeStrokeColor:changeswatch, topEdgeStrokeTint:changetint, topEdgeStrokeWeight:changeStrk};
}
if (tab.cells.bottomEdgeStrokeColor == findswatch && tab.cells.bottomEdgeStrokeTint == findtint && tab.cells.bottomEdgeStrokeWeight == findStrk)
{
s = true;
tab.cells.properties = {bottomEdgeStrokeColor:changeswatch, bottomEdgeStrokeTint:changetint, bottomEdgeStrokeWeight:changeStrk};
}
if (tab.cells.leftEdgeStrokeColor == findswatch && tab.cells.leftEdgeStrokeTint == findtint && tab.cells.leftEdgeStrokeWeight == findStrk)
{
s = true;
tab.cells.properties = {leftEdgeStrokeColor:changeswatch, leftEdgeStrokeTint:changetint, leftEdgeStrokeWeight:changeStrk};
}
if (tab.cells.rightEdgeStrokeColor == findswatch && tab.cells.rightEdgeStrokeTint == findtint && tab.cells.rightEdgeStrokeWeight == findStrk)
{
s = true;
tab.cells.properties = {rightEdgeStrokeColor:changeswatch, rightEdgeStrokeTint:changetint, rightEdgeStrokeWeight:changeStrk};
}
if (s)
strokechanges++;
}
}
}
ch = "No changes made";
if (fillchanges)
{
ch = fillchanges+" fills changed";
if (strokechanges)
ch += "\n"+strokechanges+" strokes changed";
} else if (strokechanges)
ch = strokechanges+" strokes changed";
alert (ch);
In this script only Index of table and index of cells were missing, try this code:
////////////////////////////////////////////////////////////////////
myDialog = app.dialogs.add ({name:"Recolor Tables",canCancel:true});
swatchlist = app.activeDocument.swatches.everyItem().name;
with (myDialog){
with (dialogColumns.add()){
with (borderPanels.add()){
staticTexts.add ({staticLabel:"Find"});
swf = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
Copy link to clipboard
Copied
In this script only Index of table and index of cells were missing, try this code:
////////////////////////////////////////////////////////////////////
myDialog = app.dialogs.add ({name:"Recolor Tables",canCancel:true});
swatchlist = app.activeDocument.swatches.everyItem().name;
with (myDialog){
with (dialogColumns.add()){
with (borderPanels.add()){
staticTexts.add ({staticLabel:"Find"});
swf = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
tbf = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25", "50", "75", "100"] });
tbfStrk = measurementEditboxes.add({editValue:0.5});
}
with (borderPanels.add()){
staticTexts.add ({staticLabel:"Replace"});
swr = dropdowns.add ({stringList:swatchlist, selectedIndex:0});
tbr = percentComboboxes.add({editValue:100, largeNudge:10, stringList:["25","50","75","100"] });
tbrStrk = measurementEditboxes.add({editValue:0.33});
}
with (borderPanels.add()){
dostrokes = checkboxControls.add({staticLabel:"Change strokes", checkedState:true});
dofills = checkboxControls.add({staticLabel:"Change fills", checkedState:true});
}
}
}
if (!myDialog.show() || !(dostrokes.checkedState || dofills.checkedState)){
myDialog.destroy();
exit(0);
}
findtint = tbf.editValue;
findStrk = tbfStrk.editValue;
findswatch = app.activeDocument.swatches.item(swf.selectedIndex);
changetint = tbr.editValue;
changeStrk = tbrStrk.editValue;
changeswatch = app.activeDocument.swatches.item(swr.selectedIndex);
strokes = dostrokes.checkedState;
fills = dofills.checkedState;
fillchanges = 0;
strokechanges = 0;
tb = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
for (t=tb.length-1; t>=0; t--) {
tab = tb[t];
for (c=0; c<tab.cells.length; c++){
if (fills && tab.cells[c].fillColor == findswatch && tab.cells[c].fillTint == findtint){
fillchanges++;
tab.cells[c].properties = {fillColor:changeswatch, fillTint:changetint};
}
if (strokes){
s = false;
if (tab.cells[c].topEdgeStrokeColor == findswatch && tab.cells[c].topEdgeStrokeTint == findtint && tab.cells[c].topEdgeStrokeWeight == findStrk){
s = true;
tab.cells[c].properties = {topEdgeStrokeColor:changeswatch, topEdgeStrokeTint:changetint, topEdgeStrokeWeight:changeStrk};
}
if (tab.cells[c].bottomEdgeStrokeColor == findswatch && tab.cells[c].bottomEdgeStrokeTint == findtint && tab.cells[c].bottomEdgeStrokeWeight == findStrk){
s = true;
tab.cells[c].properties = {bottomEdgeStrokeColor:changeswatch, bottomEdgeStrokeTint:changetint, bottomEdgeStrokeWeight:changeStrk};
}
if (tab.cells[c].leftEdgeStrokeColor == findswatch && tab.cells[c].leftEdgeStrokeTint == findtint && tab.cells[c].leftEdgeStrokeWeight == findStrk){
s = true;
tab.cells[c].properties = {leftEdgeStrokeColor:changeswatch, leftEdgeStrokeTint:changetint, leftEdgeStrokeWeight:changeStrk};
}
if (tab.cells[c].rightEdgeStrokeColor == findswatch && tab.cells[c].rightEdgeStrokeTint == findtint && tab.cells[c].rightEdgeStrokeWeight == findStrk){
s = true;
tab.cells[c].properties = {rightEdgeStrokeColor:changeswatch, rightEdgeStrokeTint:changetint, rightEdgeStrokeWeight:changeStrk};
}
if (s){
strokechanges++;
}
}
}
}
ch = "No changes made";
if (fillchanges){
ch = fillchanges+" fills changed";
if (strokechanges)
ch += "\n"+strokechanges+" strokes changed";
}
else if (strokechanges){
ch = strokechanges+" strokes changed";
}
alert (ch);
////////////////////////////////////////////////////////////////////
Best
Sunil
Copy link to clipboard
Copied
Hi There,
How is this question different from the one you posted at
https://community.adobe.com/t5/indesign/script-error-number-21/td-p/11159817?page=1
I suppose you mentioned that the script i rectified was working fine. I see that you are still quoting the original script, any reason to do that
-Manan
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more