1 person found this helpful
You could use the HorizontalOffset property to get the x-value of the leftmost edge of the column you're in. Seeing as all columns have the same width, it shouldn't be too difficult to figure out which you're in.
1 person found this helpful
Something like this:
textFrame = text.parentTextFrames;
textColumns = textFrame.textColumns;
curColumn = text.textColumns;
columnIndex = NaN;
columnIndex = i;
Thanks guys! Not knowing just what the .Index was returning I ended up using a combo of sorts, looping through the columns looking at the horizontal offsets of the columns and my insertion point.
One point of note I hadn't realized until working on another section of this same script was that .TextFrames(1).TextColumns.Count returns the number of columns in which the text is flowing, NOT the number of columns defined in the frame. It returns specifically only the number of columns in which the text is flowing. Using .TextFrames(1).TextFramePreferences.TextColumnCount gives, of course, the number of columns defined in the frame.
One more note on this that someone, somewhere may find useful.
When I found ...TextFrame.TextColumns(1).HorizontalOffset in the object model (VB6, InD CS3) I assumed it was the boundary of the column. It is actually the boundary of the text within the column (which actually makes sense from the name), more specifically, the FIRST TEXT LINE in that column. So only when the text sits flush left with no indention does it return the actual boundary of the column.
...TextFrame.TextColumns(1).EndHorizontalOffset seems to return the right side of the LAST line of text in that column.
Thanks again for the help,
Why are you using the horizontalOffset? That seems like a very roundabout way to find what you want. Doesn't my function do exactly what you wanted?
How about this one-liner:
myText.parentTextFrames.characters.itemByRange (0, myText.index).textColumns.length;
That gives you the VB number (first column is 1). For JS, add -1 at the end (first column = 0).
Good one Peter!
Ken, give him the star!
Getting back to this as part of another script, I wasn't able to get your brilliant one liner to work last time I was fiddling with this.
How do I define myText? I was trying to use Selection(1) like so:
TxtColNum = InD.Selection(1).ParentTextFrames(1).Characters.ItemByRange(1, InD.Selection(1).Index).TextColumns.Count
but I'm getting an error that an argument is not optional, though I can't for the life of me figure out which argument is missing.
Ken -- I've no idea. What's your selection?
Thanks for having a look Peter. The script acts on the paragraphs in the
selected text so our operators will just quickly swipe some text making
sure they've included all the paragraphs necessary. Make sense?