2 Replies Latest reply on Aug 29, 2012 5:41 AM by vDeepak

    How select text range

    Bill joy Level 1

      Hi

      I want to select some text in a textframe.

      I am using this method

      textFrame.characters.itemByRange(n,m).select();

      but characters.ItemByRange();

      give error member not found if I am using long Integer as a parameter in this.

      for example my text is AdobeIndesign and i want to select Indesign in AdobeIndesign.

      characters.ItemByRange(6,13);

       

      How use characters.ItemByRange() to select text.

      or there is another method to select a text range.

      How use character or String type parameter in characters.ItemByRange()

       

       

      Thanks.

        • 1. Re: How select text range
          Laubender Adobe Community Professional & MVP

          @Bill – with the "select()" method you can work in two ways:

           

          1. Use it with the app object like that:

           

          var whatToSelect = textFrame.characters.itemByRange(6,13);

          app.select(whatToSelect);

           

          2. Work from the object you want to select and replace any selected object with that object:

           

          var whatToSelect = textFrame.characters.itemByRange(6,13);

          whatToSelect.select(SelectionOptions.REPLACE_WITH);

           

          OR:

          You can address the object directly with a variable without selecting anything and instead do something with it (in this case assigning a fill color):

           

          var whatToAddress = textFrame.characters.itemByRange(6,13);

          whatToAddress.fillColor = "Yellow";

           

           

          Also see InDesign JavaScript Reference Guides at:

          http://www.jongware.com/idjshelp.html

           

          Uwe

          • 2. Re: How select text range
            vDeepak Level 1

            Hi Bill,

             

            1. You need to refer to first item of the result of ItemByRange. and

            2. Use character objects(startCharacter, endCharacter) as parameter for itemByRange function.

             

            Try this...

             

            var startCh = tframe.paragraphs[0].characters[5];

            var endCh = tframe.paragraphs[0].characters[12];

            tframe.paragraphs[0].characters.itemByRange(startCh,endCh).select();

             

             

             

            Thanks.