Skip to main content
Participant
June 15, 2012
Question

Get reference to textframe that the selected text is in.

  • June 15, 2012
  • 3 replies
  • 813 views

How do I get a reference to the textframe that the selected text is in?.

This topic has been closed for replies.

3 replies

Participant
June 15, 2012

Thank you for your reply. I should have thought about what I really needed. I'm trying to the the xml for the textframe of the selected text.

I have l2elements = app.selection[0].parentTextFrames[0].associatedXMLElement.xmlElements

but

lim=L2elements.length;

alert(lim)

is always 0;

Thanks in advance.

Inspiring
June 15, 2012

Edit:

Ups, a bit to late, sorry for that ...

HI,

first, selection is a array. So you have to loop through the items to get each parent text frame.

if selection[someitem] is word or paragraph you can use parentTextFrames, which is an array again

if selection[someitem] is a table it's parent ...

if selection[someitem] is a anchored object it should be parent.parentTextFrames[0]

Guess I'm missing a lot possibilities ;-)

Harbs.
Legend
June 15, 2012

text.parentTextFrames returns an array of all the textframes the specified text runs through.

so you'd want:

text.parentTextFrames[0];