I've found a work around to this problem. As far as I can tell when the line is selected the line seperator is also selected and throughs off the calculations. This code returns correct dimensions for the entire line segment (although it doesn't look like it should). I have tested it with the following.
- VB.NET and VBA
- Artistic text boxes containing one or more lines of text (various sizes illustrates the point better)
Try the following code to see the fix work.
Sub CreateAllTextLineRects()
Dim sTextLineRects As Shape
Dim line As TextRange
Dim newRange As TextRange
Dim text As String
For Each line In ActiveShape.text.Story.Lines
' redimension the TextRange to recalculate the dimensions
line.SetRange line.Start, line.Start
Set sTextLineRects = ActiveLayer.CreateCurve(line.TextLineRects)
Next
End Sub
This also works,
line.SetRange line.Start, line.End - 2
but this doesn't
line.SetRange line.Start, line.End - 1
Please try this out and let me know if there are any holes in the work around. Also note this is a work around, not a solution. For a real solution please ask Corel!