Copy link to clipboard
Copied
Hi,
I need to get the position of all texts of an Illustrator document.
It's pretty easy for single lines because I have the position of TextFrame
For each tf in docRef.TextFrames
position = tf.Position
Next
But if the TextFrame has multiple lines, I really don't know how to do.
For each tf in docRef.TextFrames
For each line in tf.Lines 'line is a TextRange
????
Next
Next
There isn't the "Position" property for TextRange objects...
I wonder if the best way would be to split/demerge lines of a TextRange into separated TextRange so I would be able to know the position of them.
But is it possible to do this ? how ? or is there another solution ?
I saw on the Internet a script to merge separated TextFrame into a single one but I would like to do the opposite...
Here is the link of the merging : http://indesignsecrets.com/merging-multiple-text-frames-into-one.php
Help 🙂
1 Correct answer
Hi Jean, there is a script to split multiline textFrames into single line textFrames, made by Wundes. But there's no need to do that...
in a 3 line textFrame
- the 1st line's position = textFrame position
- the 2nd line's position = textFrame position - Leading
- the 3rd line's position = textFrame position - Leading * 2
in the following VBA snip I did split the text and wrote the position of the lines on single frames, but you can get the position directly without splitting
Set txtFrame = Idoc.Se
...Explore related tutorials & articles
Copy link to clipboard
Copied
Hi Jean, there is a script to split multiline textFrames into single line textFrames, made by Wundes. But there's no need to do that...
in a 3 line textFrame
- the 1st line's position = textFrame position
- the 2nd line's position = textFrame position - Leading
- the 3rd line's position = textFrame position - Leading * 2
in the following VBA snip I did split the text and wrote the position of the lines on single frames, but you can get the position directly without splitting
Set txtFrame = Idoc.Selection(0)
txtLeading = txtFrame.Story.TextRange.CharacterAttributes.Leading
For i = 1 To txtFrame.Lines.Count
Set txtline = Idoc.TextFrames.Add
txtFrame.Lines(i).Duplicate txtline, 1
txtline.Position = txtFrame.Position
txtline.Top = txtline.Top - txtLeading * (i - 1)
txtline.Left = txtFrame.Left - txtFrame.Width
txtline.Contents = "Y = " & txtline.Top
Next
Copy link to clipboard
Copied
Hi,
Pretty cool !
I would never thought to do this like that.
Very helpful thank you !

