And one another thing danaken3,
Some header rows conain bottom line with years and LKR '000. This part also need to adjust with the figures. Do you have any idea about how to do that? If this script can't do that, any new script for run again? No matter to use two mouse clicks per table....... I am happy enough.....
Ah I see -- try this one:
app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){
/*Searches for all instances of "Table_Figures" paragraph style.
(Paragraph style must be saved within the "Table_Styles" folder.)
For each result, finds width of parent cell. Overrides the first
(existing) tab stop position to: cell width minus 2mm.
Deletes all other tab stops.*/
app.findGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Table_Styles").paragraphStyles.item("Table_Figures");
var myResults = app.findGrep();
var myCell;
var origViewMeasurements = app.activeDocument.viewPreferences.horizontalMeasurementUnits;
app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
for (i=0; i<myResults.length; i++) {
try {
if (myResults[i].tabStops.length > 1) {
for (j=myResults[i].tabStops.length-1; j>0; j--) {
myResults[i].tabStops[j].remove();
}
}
myCell = myResults[i].parent;
myResults[i].tabStops[0].position = myCell.width - 2;
}
catch(err) {
}
}
/*Searches for all instances of "Table_Header" paragraph style.
(Paragraph style must be saved within the "Table_Styles" folder.)
For each result, finds width of parent cell. Overrides the first
(existing) tab stop position to: cell width minus 2mm.
Deletes all other tab stops.*/
app.findGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Table_Styles").paragraphStyles.item("Table_Header");
myResults = app.findGrep();
app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
for (i=0; i<myResults.length; i++) {
try {
if (myResults[i].tabStops.length > 1) {
for (j=myResults[i].tabStops.length-1; j>0; j--) {
myResults[i].tabStops[j].remove();
}
}
myCell = myResults[i].parent;
myResults[i].tabStops[0].position = myCell.width - 2;
}
catch(err) {
}
}
app.findGrepPreferences = NothingEnum.nothing;
app.activeDocument.viewPreferences.horizontalMeasurementUnits = origViewMeasurements;
alert("Script complete");
}