Copy link to clipboard
Copied
Hi Pros,,
Again i tried to remove the table styles depending on the previous technique but nothing happened even no error message?!, Please Help me making code works and thanks in Advance :
//Remove Unused Table Styles
removeUnusedTableStyles();
function removeUnusedTableStyles() {
var TableStyles, found,
documentStories = app.activeDocument.stories.everyItem();
TableStyles = documentStories.tables.everyItem().getElements();
for (var i = TableStyles.length - 1; i >= 1; i--) { // skip default style: [None]
app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.table.appliedTableStyle.name = TableStyles[i];
found = TableStyles.table.appliedTableStyle.name();
if (found.length == 0) {
TableStyles[i].remove();
}
}
app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
}
Best
medos20
Hi Medos,
I don't see the table property existing in findTextPreferences object, so this code would crash. I don't see the same in grep search preference as well, so this idea might not work for table styles.
What I can think of is the old school way of iterating over all the tables in the document, make a list of used styles and then delete the styles that do not exist in this list
-Manan
Copy link to clipboard
Copied
Hi Medos,
I don't see the table property existing in findTextPreferences object, so this code would crash. I don't see the same in grep search preference as well, so this idea might not work for table styles.
What I can think of is the old school way of iterating over all the tables in the document, make a list of used styles and then delete the styles that do not exist in this list
-Manan
Copy link to clipboard
Copied
Thank you, Can you show me Example? at least small one, Thanks in Advance
Best
medos20