10 Replies Latest reply on May 26, 2011 10:50 AM by csm_phil

    Break link to style script

    JimMcAndrew

      Can someone help me write a script that will "Break link to style" for all paragraph styles and character styles for all text on a spread but keep the formatting?

       

      Thanks,

       

      Jim

        • 1. Re: Break link to style script
          JimMcAndrew Level 1

          I forgot to add that this is for CS4

          • 2. Re: Break link to style script
            csm_phil Level 4

            Hi Jim,

             

            You have to try my below JS Code, i am using Menu Actions;

             

            #target "InDesign-6.0"
            var myDoc = app.activeDocument;

             

            for (i=0; i<myDoc.stories.length; i++){
                for (j=0; j<myDoc.stories[i].paragraphs.length; j++){
                    app.select(myDoc.stories[i].paragraphs[j]);
                    //Break paragraph styles
                    BreakParaStyle = app.menuActions.itemByID(8500);
                    try {
                        BreakParaStyle.invoke();
                        }
                    catch (err){};
                    //Break character styles
                    BreakCharStyle= app.menuActions.itemByID(8501);
                    try {
                        BreakCharStyle.invoke();
                        }
                    catch (err){};
                    app.selection = null;
                    }
                }
            alert("Done");

             

            thx

            csm_phil

            • 3. Re: Break link to style script
              JimMcAndrew Level 1

              Thanks Phil.

               

              I tried this, but it does not retain all of the original formatting.

               

              Any suggestions?

               

              Jim

              • 4. Re: Break link to style script
                csm_phil Level 4

                Hi Jim,

                 

                Its working for me good, if you done mine can you please post your document.

                 

                thx

                csm_phil

                • 5. Re: Break link to style script
                  JimMcAndrew Level 1

                  Unfortunately, I can't. I'm under a non-disclosure as to the doc I'm working on.

                   

                  Jim

                  • 6. Re: Break link to style script
                    csm_phil Level 4

                    Hi Jim,

                     

                    Can you send the snapshot of the error or you document.

                     

                    thx

                    csm_phil

                    • 7. Re: Break link to style script
                      Laubender Adobe Community Professional & MVP

                      csm_phil,

                      did you test your script with a rather complex document? With rather complex I think of paragraph styles based on each other, same paragraph names in different subfolders, character styles, GREP styles, object styles, cell styles, list styles …

                       

                      To break all the links to the styles, it might be important to keep a distinct order.

                       

                      Try to remove the styles in the following order:

                       

                      (( 0. Cell styles (sometimes it was inevitable for me to delete cell styles to perform the task without a script, but I did not research or recall the exact conditions ))

                       

                      1. Character Styles
                      2. Paragraph Styles

                       

                      Hope that helps,

                       

                      Uwe

                      • 8. Re: Break link to style script
                        csm_phil Level 4

                        Hi Laubender,

                         

                        Yes, i have tried the above mentioned code in the simple InDesign document this contains all paragraphstyles and characterstyles and break to link style its worked fine.

                         

                        you can create the simple document and you use the js code it will work or not if the script is worked can you include whatever things you needed.

                         

                        thx

                        csm_phil.

                        • 9. Re: Break link to style script
                          JimMcAndrew Level 1

                          Somehow Indesign is seeing an attachment to a style that does not even exist in the doc anymore. Very Strange. I don't think breaking the link to styles will help me anymore. I am trying to figure out why my files continue to crash after I format type with a Korean font. Thought the font was bad, purchased new copy, same issue. Noticed it would always bomb related to a certain style which contained nested styles, hence the idea to break link to style. But how can you break a link to a style that doesn't exist anymore.

                           

                          I think I may need to reinstall indesign and see if I continue to have the issue with these docs.

                           

                          Thanks for your help.

                           

                          Come to think of it, how would you write a script to delete all unused paragraph styles and character styles. Is that possible?

                           

                          Jim

                          • 10. Re: Break link to style script
                            csm_phil Level 4

                            Hi Jim,

                             

                            You can use the Harbs Script delete the ParagraphStyles.

                             

                            I give the  reference link: http://forums.adobe.com/message/2286470#2286470

                             

                            You can clear the InDesign Preferences:

                            MAC:         cmd+opt+shift press and open simultaneously the InDesign CS4.

                            Windows:   ctrl+alt+shift   press and open simultaneously the InDesign CS4.

                             

                             

                            thx

                            csm_phil