2 Replies Latest reply on Jul 15, 2013 5:07 AM by BEGINNER_X

    Place Cursor before a specific word

    schiuma24 Level 1

      is there anyway  I can place the blinking type cursor before the word "hotel" that´s inside a cell with Javascript!?!?

        • 1. Re: Place Cursor before a specific word
          Jump_Over Level 5

          Hi,

           

          cursor moved before first word "hotel" found in myDoc:

           

          myDoc = app.activeDocument;
          app.findTextPreferences = null;
          app.findTextPreferences.findWhat = "hotel";
          mWord = myDoc.findText()[0];
          if (mWord) 
               mWord.insertionPoints[0].select();
          else 
               (alert ("not found") );
          
          

           

          Jarek

          • 2. Re: Place Cursor before a specific word
            BEGINNER_X Level 3

            Hi schiuma,

             

            Could you please use this code also.

             

            Only difference from the above code is  "if(myFound[i].parent.constructor.name == "Cell")"

             

             //Code is below
            var myDoc = app.activeDocument;
             app.findTextPreferences.findWhat = "hotel";
             var myFound = myDoc.findText();
             for(i=0; i<myFound.length; i++)
            {
                if(myFound[i].parent.constructor.name == "Cell")
                {
                    myFound[i].insertionPoints[0].select();
                    }
                else
                {
                    alert("not found")
                    }
                 }
            

             

             

            Thanks

            Beginner