Skip to main content
Inspiring
August 3, 2022
Answered

Get the parent TextFrame of a marker using ExtendScript (Unstructured)

  • August 3, 2022
  • 1 reply
  • 372 views

Hi,

I am a newbie in ExtendScript. In my document, I have a couple of TextFrames which contain hyperText markers. Using ExtendScript I can get all the HyperText markers. Now I want to get the parent of each marker via script. But I couldn't find anything in the documentation.

Any help or suggestion would be appreciated.

Sanam  

This topic has been closed for replies.
Correct answer frameexpert

A marker will have a TextLoc property and you can use this to get the parent TextFrame. Something like this:

var textFrame;

// Assuming marker is your Marker object and doc is your Doc object.
textFrame = getTextFrame (marker.TextLoc, doc);

function getTextFrame (textLoc, doc) {

    var prop, textFrame;
	
	 // Get the text frame from the text location.
	prop = doc.GetTextPropVal (textLoc, Constants.FP_InTextFrame);
	if ((prop.propIdent.num) && (prop.propVal.obj)) {
		textFrame = prop.propVal.obj;
		return textFrame;
	}
}

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
August 3, 2022

A marker will have a TextLoc property and you can use this to get the parent TextFrame. Something like this:

var textFrame;

// Assuming marker is your Marker object and doc is your Doc object.
textFrame = getTextFrame (marker.TextLoc, doc);

function getTextFrame (textLoc, doc) {

    var prop, textFrame;
	
	 // Get the text frame from the text location.
	prop = doc.GetTextPropVal (textLoc, Constants.FP_InTextFrame);
	if ((prop.propIdent.num) && (prop.propVal.obj)) {
		textFrame = prop.propVal.obj;
		return textFrame;
	}
}
sanam.dehAuthor
Inspiring
August 4, 2022

@frameexpert thank you for your help.