6 Replies Latest reply on Dec 30, 2014 11:45 PM by Laubender

    Stumped... Multiple textFrame Contents

    BrettA Level 1

      Oh... help would be so greatly appreciated as, I am truly stumped!


      Selecting two (or more) text frames manually, how can one go about looping through and changing the properties of all the type contained in each of the frames? I'm only using the "with" statement so, any additional properties added will be easy to find and read.

       

      var mySel = app.selection[0].contents;

       

           for (i=0; i<mySel.length; i++) {

                with (mySel){

                     horizontalScale = 200;

                     kerningMethod = "Optical";

                }

           }

       

      Thanks again for any help!

        • 1. Re: Stumped... Multiple textFrame Contents
          TᴀW Adobe Community Professional & MVP

          Well, if you're selecting more than one frame, selection[0] will be the

          first frame, and selection[1] the second, and so on. So you would need

          to loop through the selection array to get at all your text frames.

          • 2. Re: Stumped... Multiple textFrame Contents
            BrettA Level 1

            Yeah, I think it's an issue with the way I am referencing the contents of the frames in the DOM. With the [0] or [1] it does affect only that specific frame in a multiple selection but, if I omit the [0] from the app.selection I can't get anything but "undefined".

            • 3. Re: Stumped... Multiple textFrame Contents
              TᴀW Adobe Community Professional & MVP

              app.selection is always an array. You have to use an index to access it.

              • 4. Re: Stumped... Multiple textFrame Contents
                pixxxel schubser Level 5

                Hi BrettA,

                there are more than one way to do what you want.

                 

                E.g. you can try someting like this:

                // select one or more text frames before
                var mySel = app.selection;
                
                for (i=0; i<mySel.length; i++) {
                    with (mySel[i].paragraphs.everyItem()){
                        horizontalScale = 200;
                        kerningMethod = "Optisch"; // for german language
                        //kerningMethod = "Optical"; // for english language
                        }
                    }
                

                 

                It seems to be so, that the »kerningMethod string« should be in your own language.

                Have fun

                 

                • 5. Re: Stumped... Multiple textFrame Contents
                  BrettA Level 1

                  Thanks pixxxel & Ariel!, that's working great! it was the ".paragraphs.everyItem" that I wasn't getting around to, for some reason ".contents" was working for a single selection but did nothing to them in an array.

                  • 6. Re: Re: Stumped... Multiple textFrame Contents
                    Laubender Adobe Community Professional & MVP

                    @pixxxel schubser – there is a unique string for "Optical" kerning method that is working for all languange versions of InDesign:

                     

                    You could find it, if you are using the app.findKeyStrings() method in your German ESTK:

                     

                    app.findKeyStrings("Optisch");
                    

                     

                    will return the string: "$ID/Optical"

                     

                    Uwe

                    • 7. Re: Re: Stumped... Multiple textFrame Contents
                      Laubender Adobe Community Professional & MVP

                      @BrettA – instead of paragraphs.everyItem() you could address the texts[0] object of every text frame. Or in case of overset text the whole parent story by parentStory.texts[0].

                       

                      Using texts[0] or parentStory.texts[0] has the advantage, that text frames without contents are triggered for the horizontal scale and the kerning method. Using paragraphs.everyItem() will not work on empty text frames, simply because there are no paragraphs there:

                       

                      // select one or more text frames before 
                      var mySel = app.selection; 
                      
                      for (i=0; i<mySel.length; i++) {
                         
                          with (mySel[i].texts[0]){ 
                              horizontalScale = 200; 
                              kerningMethod = "$ID/Optical"; // for all languages
                              }
                         
                          }
                      

                       

                      And ".contents" has nothing to do with formatting anything.

                       

                      Uwe