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

Remove unused Styles using actions

Contributor ,
Jun 27, 2015 Jun 27, 2015

Hi,

   I need to delete unused paragraph styles in document using action, until selection of unused style count is 0. 

   I saw  the below url in this forum.  Can i do this using action???

remove unused styles in one action...

Thanks in advance,

Sudha K

TOPICS
Scripting
1.1K
Translate
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

Explorer , Jun 30, 2015 Jun 30, 2015

Hi,

It will not make any change. However, please create pdf and compare with old one to check this. If my answer is correct, please mark it as correct answer so that it will be reference to others.

Thanks

K Ramesh

Translate
Explorer ,
Jun 28, 2015 Jun 28, 2015

Hi,

Please use this script. It might be helpful to you.

var myDoc = app.activeDocument; 
var myParStyles = myDoc.paragraphStyles; 
var myCharStyles = myDoc.characterStyles; 
for (i = myParStyles.length-1; i >= 2; i-- ){ 
   removeUnusedParaStyle(myParStyles
for (i = myCharStyles.length-1; i >= 1; i-- ){ 
   removeUnusedCharStyle(myCharStyles
function removeUnusedParaStyle(myPaStyle) { 
   app.findTextPreferences = app.changeTextPreferences=null;
   app.findTextPreferences.appliedParagraphStyle = myPaStyle; 
   var myFoundStyles = myDoc.findText(); 
      if (myFoundStyles == 0) { 
         myPaStyle.remove(); 
     
   app.findTextPreferences = app.changeTextPreferences=null;   
function removeUnusedCharStyle(myChStyle) { 
   app.findTextPreferences = app.changeTextPreferences=null;
   app.findTextPreferences.appliedCharacterStyle = myChStyle; 
   var myFoundStyles = myDoc.findText(); 
      if (myFoundStyles == 0) { 
         myChStyle.remove(); 
     
   app.findTextPreferences = app.changeTextPreferences=null; 

alert(" All Unused Styles removed Successfully");

Translate
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
Contributor ,
Jun 28, 2015 Jun 28, 2015

Hi,

Thank you... Can we do this using menu action??

I can remove styles using menu action using the below code.

try{

app.menuActions.itemByID(8474).invoke();

app.menuActions.itemByID(8451).invoke();

}catch(e){

app.menuActions.itemByID(8450).invoke();

app.menuActions.itemByID(8474).invoke();

app.menuActions.itemByID(8451).invoke();

}

But my prob is the dialog box appeared when run the code. How can i escape that dialog without mapping style??

Screen shot 2015-06-29 at 9.51.13 AM.png

- Sudha K

Translate
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
Explorer ,
Jun 29, 2015 Jun 29, 2015

Hi,

if Unused style is "based on" to another style, it will ask replace any style with unused style. Please find the style in which the "based on" style(unused) has been used and redefine it. Then you can run script. It will not show the dialog to replace any style. I hope this will work.

Thanks

K Ramesh

Translate
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
Contributor ,
Jun 30, 2015 Jun 30, 2015

Hi,

Thank you. yes its working now.

If i change based on to "[No Paragraph Style]" and Next style to "[Basic Paragraph]", will it make any changes in document???

- Sudha K

Translate
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
Explorer ,
Jun 30, 2015 Jun 30, 2015

Hi,

It will not make any change. However, please create pdf and compare with old one to check this. If my answer is correct, please mark it as correct answer so that it will be reference to others.

Thanks

K Ramesh

Translate
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
Contributor ,
Jul 01, 2015 Jul 01, 2015
LATEST

Hi,

  Thank you...

Translate
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