Answered
Retrieve number of the column of searched text
Hi,
I am looking for how, with a GREP search, to retrieve the number of the column of the searched text, when this one is in a multi-column text frame.

Thanks for your help.
Ronald
Hi,
I am looking for how, with a GREP search, to retrieve the number of the column of the searched text, when this one is in a multi-column text frame.

Thanks for your help.
Ronald
You could try this:
var s = app.documents.item(0).selection[0];
var ho = s.horizontalOffset;
var cc = s.parentTextFrames[0].textFramePreferences.textColumnCount;
var cw = s.parentTextFrames[0].textFramePreferences.textColumnFixedWidth;
var g = s.parentTextFrames[0].textFramePreferences.textColumnGutter;
var x = s.parentTextFrames[0].geometricBounds[1]
for (var i = 0; i < cc; i++){
var cx = i*(cw+g) + x;
if (ho >= cx && ho < cx + cw) {
alert("Selected text starts in column " + (i+1))
}
};

Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.