2 Replies Latest reply on Apr 14, 2009 3:01 AM by littlemookie

    Turn hyphenation off

    littlemookie Level 1

      Hi there,

       


      I have a script that will turn off Hyphenation in all the Paragraph Styles used in a document, but not all of the text have paragraph styles assigned to them, so my script keeps missing them out.

       

      Is there a script that will turn off hyphenation for all text frames/paragraphs in a document?

       

      Maybe find hyphenation = true, change to hyphenation = false?

       

      Any help at all on this one will help me out no end.

       

      Cheers,

       

      Littlemookie

        • 1. Re: Turn hyphenation off
          [Jongware] Most Valuable Participant

          In "correctly formatted text" everything should have a paragraph style, but even if you change the style, it doesn't mean the text changes as well -- it might have been overridden. So, yeah, do a separate run to be sure.

          Find & replace is extremely fast -- but ... it doesn't support changing hyphenation! A few options are available in scripting and not in the interface (hyphenateAcrossColumns, hyphenateLastWord), but that doesn't help.

          So, since you mention "in an entire document", let's just iterate over all stories, and inside those, over all paragraphs.

           

          for (var i=app.activeDocument.stories.length-1; i>=0; i--)
          {
          for (var j=app.activeDocument.stories[i].paragraphs.length-1; j>=0; j--)
            app.activeDocument.stories[i].paragraphs[j].hyphenation = false;
          }

          As usual, it's safest to loop backwards over items. I can't tell for sure, but changing the hyphenation setting just might upset the natural order items are in.

          • 2. Re: Turn hyphenation off
            littlemookie Level 1

            Again Dude, you've sorted it!

             

            Many thanks, that has worked a treat.

             

            Top notch, top notch!

             

            Peace!