Copy link to clipboard
Copied
I've tried some codes on the internet and they all failed. There doesn't seem to be any online for individual tables.
A. I am trying to clear the table style “Preferred Options”.
B, cell styles “preferred options”, “non-custom style properties”.
C. Paragraph styles “Preferred Options”.
D. Apply character style “none”.
For example, this sentence wants to clear the cell style priority.
myTable.everyItem().cells.everyItem().paragraphs.everyItem().clearOverrides(myOverrideType);
I have a feeling it's the front of clearOverrides that's wrong.
Someone would like to point it out.
Here's a script that's a little complicated.
Is there anything that can be done in a couple of sentences?
https://raw.githubusercontent.com/grefel/clearOverrides/refs/heads/master/ClearStyleOverrides.jsx
I added these two lines and it seemed to work, but the “undefined style attribute” was not cleared.
myTable.clearTableStyleOverrides();
myTable.cells.everyItem().clearCellStyleOverrides();
Hello,
Your goal of clearing table, cell, and paragraph styles and applying the "None" character style efficiently, here's a streamlined script in Adobe InDesign scripting (JavaScript):
// Clear table style overrides
myTable.clearTableStyleOverrides();
// Clear cell style overrides
myTable.cells.everyItem().clearCellStyleOverrides();
// Clear paragraph style overrides
myTable.cells.everyItem().paragraphs.everyItem().clearOverrides();
// Apply "None" character style
var noneCharStyle = myDocument.charac
Copy link to clipboard
Copied
Not sure whether that solves your problem, but clearCellStyleOverrides() has an optional argument.
Copy link to clipboard
Copied
How do I use it?
Copy link to clipboard
Copied
The parameter is a boolean. Use true or false.
That (Optional) means you can leave the parameter out, as you initially did.
Unfortunately the description does not tell whether true or false is the default.
Copy link to clipboard
Copied
useless。
I've tried all of these below, and I suspect that the description of the position in front of clearOverrides is wrong。
try{
myTable.clearTableStyleOverrides();
myTable.cells.everyItem().clearCellStyleOverrides();
myTable.rows.everyItem().cells.everyItem().clearOverrides(OverrideType.ALL);
myTable.everyItem().clearTableStyleOverrides(OverrideType.ALL);
myTable.everyItem().cells.everyItem().clearCellStyleOverrides(OverrideType.ALL);
myTable.texts[0].clearOverrides(OverrideType.ALL);
}
catch(e){};
Copy link to clipboard
Copied
you don't initialize myTable.
Also you are passing OverrideType.ALL to clearCellStyleOverrides() instead of true or false.
Besides the separate try-catch that you eliminated in the other thread still make sense, as you write it InDesign will only execute until the first error line and skip the others.
Without doing anything about the exception e from the catch(e), you won't even know where the script fails.
Copy link to clipboard
Copied
The myTable is initialized on the front side.
Copy link to clipboard
Copied
Hello,
Your goal of clearing table, cell, and paragraph styles and applying the "None" character style efficiently, here's a streamlined script in Adobe InDesign scripting (JavaScript):
// Clear table style overrides
myTable.clearTableStyleOverrides();
// Clear cell style overrides
myTable.cells.everyItem().clearCellStyleOverrides();
// Clear paragraph style overrides
myTable.cells.everyItem().paragraphs.everyItem().clearOverrides();
// Apply "None" character style
var noneCharStyle = myDocument.characterStyles.itemByName("[None]");
myTable.cells.everyItem().paragraphs.everyItem().appliedCharacterStyle = noneCharStyle;
Clear Table Style Overrides: myTable.clearTableStyleOverrides(); removes table-level overrides.
Clear Cell Style Overrides: myTable.cells.everyItem().clearCellStyleOverrides(); clears all cell-level styles.
Clear Paragraph Style Overrides: myTable.cells.everyItem().paragraphs.everyItem().clearOverrides(); removes any overrides applied to paragraphs in the table.
Apply "None" Character Style: This ensures no character styles are applied, setting the text to the default "[None]" style.
Replace myTable with your specific table reference in the script.
Ensure your document is correctly referenced with myDocument.
"[None]" is the default character style name in InDesign, so this line works universally.
If "undefined style attributes" persist, ensure no conflicting custom styles are being reapplied afterward. This script should comprehensively reset all styles in a clean and efficient manner.
Copy link to clipboard
Copied
Thank you very much.
This basic, universally applicable stuff is so important.
Thanks for sharing such great tips.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now