Skip to main content
Obi-wan Kenobi
Legend
November 9, 2016
Question

Code to be evaluated! [007] // Grep Research and Text Frame …

  • November 9, 2016
  • 1 reply
  • 282 views

Hi Scripters,

I make a Grep research on a "XXX" para style and I want, after, to manipulate the text frame containing the paras I found!

So, is this code correct to begin?

var myDoc = app.activeDocument;       

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.appliedParagraphStyle = "XXX";

var myFound = myDoc.findGrep();

for(var F = 0; F < myFound.length; F++) 

    {

        var myTextFrame = myFound.parent.textFrames;

        //………

    }

Thanks in advance! 

(^/)

This topic has been closed for replies.

1 reply

Peter Kahrel
Community Expert
Community Expert
November 9, 2016

1. Open the ESTK, open the Console.

2. Select some text in an InDesign document.

3. In the ESTK console, enter app.selection[0].parent and press Enter

4. What does the console reply?

P.

Obi-wan Kenobi
Legend
November 9, 2016

Hi Peter!

app.selecton[0].parent  =>  Result : [object Story]

app.selecton[0].parent.textFrames  =>  Result : [object TextFrames]

… So, I'm right!? 

(^/)

Peter Kahrel
Community Expert
Community Expert
November 9, 2016

Try this:

app.selecton[0].parent.textFrames.length

=> Result: 0

So that doesn't work.

Go to the OMV, look under any text property, e.g. Character. You'll see that it has a property 'parent', but you already found that that doesn't work. After 'parent' is 'parentTextFrames'. Try that:

app.selection[0].parentTextFrames

and see what happens.

Be adventurous!

P.