Copy link to clipboard
Copied
Hello,
I'm looking for a script that allows me to correct cell style overrides in a table.
I found one but it is not restrictive enough, I would like it to fix all the replacements except when the style "without" is associated with the cell.
Thank you in advance.
You may try this below code:
if(app.documents[0].stories.everyItem().tables.everyItem().length > 0){
var cells = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements();
for(var i = 0; i < cells.length; i++){
if(cells[i].appliedCellStyle.name.toLowerCase() != "without"){
cells[i].clearOverrides (true);
}
}
}
Best
Sunil
Copy link to clipboard
Copied
here is the script I am currently using:
// Clear All Overrides
// Written by TAW. (c) 2014 by Bookraft Solutions, Israel (Id-Extras.com)
// Please do not delete this copyright notice.
//
var myOverrideType = OverrideType.ALL;
// var myOverrideType = OverrideType.CHARACTER_ONLY;
// var myOverrideType = OverrideType.PARAGRAPH_ONLY;
var allStories = app.activeDocument.stories.everyItem();
// Remove overrides from all stories
try{
allStories.clearOverrides(myOverrideType);
}
catch (e){alert ("No stories!")}
// Remove overrides from all footnotes
try{
allStories.footnotes.everyItem().texts.everyItem().clearOverrides(myOverrideType);
}
catch (e){alert ("No footnotes!")}
// Remove overrides from all table
try{
allStories.tables.everyItem().cells.everyItem().paragraphs.everyItem().clearOverrides(myOverrideType);
}
catch (e){alert ("No tables!")}
alert("Overrides cleared!");
// Remove overrides from all cells
try{
allStories.tables.everyItem().cells.everyItem().clearCellStyleOverrides(true);
}
catch (e){alert ("No tables!")}
Copy link to clipboard
Copied
So you want to clear overrides only withing Cell?
Or only outside of cell?
Best
Sunil
Copy link to clipboard
Copied
You may try this below code:
if(app.documents[0].stories.everyItem().tables.everyItem().length > 0){
var cells = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements();
for(var i = 0; i < cells.length; i++){
if(cells[i].appliedCellStyle.name.toLowerCase() != "without"){
cells[i].clearOverrides (true);
}
}
}
Best
Sunil