Skip to main content
Participant
January 29, 2019
Answered

Clear Overrides with .jsx

  • January 29, 2019
  • 2 replies
  • 568 views

Hi

New to scripting. I have the following which means cells within a table which have a paragraph style on them will be changed to a cell style. It works perfectly EXCEPT it will not clear overrides in the table.

I understand there is some more script I should add in to make that happen? But I can't work out what or where.

Please help!

function findTable(obj)

{

while (obj.constructor.name != "Table")

{

obj = obj.parent;

if (obj.constructor.name == "Application")

{

throw "Can’t find table";

}

}

return obj;

}

var myTable = 0;

if (app.documents.length > 0 && app.selection.length > 0)

{

myTable = findTable(app.selection[0]);

//Find styles cells formater

if (myTable.constructor.name == "Table")

{

app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

app.findTextPreferences.appliedParagraphStyle = "Heading 2";

var myCellStyle = myTable.findText();

app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

}

if (myCellStyle.length > 0)

{

for (var c = 0; c < myCellStyle.length; c++)

{

myCellStyle.parent.appliedCellStyle = "myCellStyle";

}

} else

{

alert("Not found");

}

}

This topic has been closed for replies.
Correct answer Manan Joshi

Try the following line under the line where you are applying the cell style

myCellStyle.parent.clearCellStyleOverrides()

-Manan

2 replies

RachelTFSAuthor
Participant
January 29, 2019

Thank you so much!

Manan JoshiCommunity ExpertCorrect answer
Community Expert
January 29, 2019

Try the following line under the line where you are applying the cell style

myCellStyle.parent.clearCellStyleOverrides()

-Manan

-Manan