• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Remvoe Unused Table Styles

Enthusiast ,
Aug 21, 2020 Aug 21, 2020

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

Best
Mohammad Hasanin
TOPICS
Scripting

Views

230

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 21, 2020 Aug 21, 2020

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

Votes

Translate

Translate
Community Expert ,
Aug 21, 2020 Aug 21, 2020

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 21, 2020 Aug 21, 2020

Copy link to clipboard

Copied

LATEST

Thank you, Can you show me Example? at least small one, Thanks in Advance

Best

medos20

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines