0 Replies Latest reply on Dec 29, 2014 8:15 AM by BrettA

    If Switch equals (more than 1) selection, then loop through contents?

    BrettA Level 1

      The following script is working great for me using an insertion point, or not selecting anything and letting it apply to everyItem... yet, using the "Selection Tool" and pre selecting more than one text frame; it is only applying to the first text frame. I know a loop is needed and since I'm using a "with" statement, I'm fumbling with where to utilize the loop to adapt the switch to "if" there are multiple frames currently selected.


      Any help, would likely teach me alot! and would be greatly appreciated!


         and... if I had a second question regarding this script, it is that the section that has the Min - Desired - Max justification settings occasionally errors out, if the the settings are currently lesser than a value (i.e. try to script in Desired Scale of 50 if Min is already set to 51), it gets mad, just like the actual dialog box does. Can that be wrapped in a loop that can catch the errors, while looping a few times to trying to force the settings? I've tried reordering it multiple ways, some work better than others but, still on occasion it'll get an error.


      Thanks again! and by-the-way, these settings result in a super flexible (single-line) text frame that works good with variable data without over-flowing (squish or stretch) text. And... for some reason "Word Spacing & Letter Spacing" with both the min and desired being set to the same value (i.e. Min 40% - Desired 40%) seems to be the key to making it behave (seems like a bug) InDesign CS5.5..



      if(app.selection.length != 0){

          var myTexts = app.selection[0];

          switch (myTexts.constructor.name){

              case "TextFrame":

              var myTexts = app.selection[0].texts[0]; break;

              case "InsertionPoint":

              var myTexts = app.selection[0].paragraphs[0]; break;

              default: var myTexts = app.selection[0];




              myTexts = app.activeDocument.stories.everyItem().texts[0];



          with (myTexts)


      hyphenation = false;

      composer = "Adobe Single-line Composer";

      noBreak = true;

      kerningMethod = "Optical";

      ignoreEdgeAlignment = true;

      justification = Justification.CENTER_ALIGN;

      singleWordJustification = SingleWordJustification.CENTER_ALIGN;


      maximumWordSpacing = 1000;

      maximumLetterSpacing = 500;

      maximumGlyphScaling = 200;


      minimumWordSpacing = 100;

      minimumLetterSpacing = 40;       

      minimumGlyphScaling = 50;


      desiredWordSpacing = 100;

      desiredLetterSpacing = 40;

      desiredGlyphScaling = 200;


      tracking = 0;

      horizontalScale = 1000;