Skip to main content
dublove
Legend
Oct 24, 2026 12:55 PM UTC
Answered

How to use a script to select some text in a continuous column and then convert it to select all the text in these columns?

For example, my story has 4 text boxes, each with 2 columns.
When I select some of the text in columns 2-4, I want to use a script to select all the text in columns 2-4.

The green color in the sample represents the selected text

    Peter Kahrel
    Peter KahrelCorrect answer
    Community Expert
    Oct 24, 2026 2:55 PM UTC

    You should familiarise yourself with the textColumn object and the itemByRange() function. Many of your questions are about that.

    app.selection[0].parentStory.textColumns.itemByRange (
    app.selection[0].textColumns[0],
    app.selection[0].textColumns[-1])
    .select();

     

    12 replies

    Peter Kahrel
    Community Expert
    Community Expert
    Oct 27, 2026 8:48 AM UTC

    >  want to get the starting line, which is the first line in the story, because it's easier to control.

    Why is that?

    > The lines [0]. index seems to obtain the character position, not the position of lines [0].

    The position of a line is the same as the position of the line’s first character and the line’s first insertion point.

    > What line is it in 'app. selection [0]. parentStory. lines'

    I distinctly remember that you’ve asked this question several times before and got answers. With all the hints and code samples you received over the years you should really be able to do this yourself. Try it. Hint: use itemByRange()

    Translate
    dublove
    dubloveAuthor
    Legend
    Oct 25, 2026 2:44 AM UTC

    I have been restricted from speaking again.
    Am I a bad person?
    Or am I just pouring water?

    Translate
    Peter Kahrel
    Community Expert
    Peter KahrelCommunity ExpertCorrect answer
    Community Expert
    Oct 24, 2026 2:55 PM UTC

    You should familiarise yourself with the textColumn object and the itemByRange() function. Many of your questions are about that.

    app.selection[0].parentStory.textColumns.itemByRange (
    app.selection[0].textColumns[0],
    app.selection[0].textColumns[-1])
    .select();

     

    Translate
    m1b
    Community Expert
    Community Expert
    Oct 24, 2026 3:16 PM UTC

    Beautiful! I’m so glad you posted this before I posted my ~70 line monstrosity! :)

    Translate