Skip to main content
Inspiring
July 15, 2013
Question

Place Cursor before a specific word

  • July 15, 2013
  • 1 reply
  • 557 views

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

This topic has been closed for replies.

1 reply

Jump_Over
Legend
July 15, 2013

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

BEGINNER_X
Legend
July 15, 2013

Hi schiuma,

Could you please use this code also.

Only difference from the above code is  "if(myFound.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.parent.constructor.name == "Cell")

    {

        myFound.insertionPoints[0].select();

        }

    else

    {

        alert("not found")

        }

     }

Thanks

Beginner