Thanks Colin for the inputs. I tried it but it seems there’s something missing.
I think I have ordered the script correctly.
The script just applies the myTableStyle but didn’t remove the overrides completely.
Secondly, I need a script to do as:
1/ Apply the myTableStyle style to the current table. By current table I mean the table with Cursor in it.
2/ Format the table with Alternate Fills (the existing style do not have the Alternating Fills, I am not supposed to edit it).
2.1/ First 1 Row : Color: None
2.2/ Next 1 Row : Color: Black 20%
And another script to:
1/ Apply the myTableStyle style to the current table. By current table I mean the table with Cursor in it.
2/ Format the table with Alternate Fills (the existing style do not have the Alternating Fills, I am not supposed to edit it).
2.1/ First 1 Row : Color: None
2.2/ Next 1 Row : Color: Black 20%
3/ Convert the the first row to header of the current table.
app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");
function checkUserSelection ()
{
var a_table = checkWhichTable();
if (a_table == null)
{
if (confirm("No table selected. Do you want to process all tables?") == false)
return;
allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
for (aTable=0; aTable < allTables.length; aTable++) { processTable (allTables[aTable]); } } else { processTable (a_table); } }
function processTable(table)
{
table.appliedTableStyle = "Table_Alternating-Fills";
}
function checkWhichTable()
{
// ensure the user made a selection
if (app.selection.length != 1)
return null;
var currentTable = app.selection[0];
if (currentTable.hasOwnProperty("baseline"))
{
currentTable = app.selection[0].parent;
}
while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
currentTable = currentTable.parent;
if (!(currentTable instanceof Table))
{
// No table selected
return null;
}
return currentTable;
}