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];
  //alert (tb.length)
  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);