Hi,
I'm using Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary) to calculate the width of a line in a 2010 Word document.
A line in a 8.5 X 11" document measures 457.9 across from the left to right margins if I place the IP between the second to last character and the last. (If I put the IP after the last it returns 0.
6.5 x 72 = 468 so I guess the measurement is in points, but off by a few, even including the last letter (5.0+points).
Oddly when I tally all the character widths (of a string of numbers without blank spaces) in a 6.5" line using an array using the code below I get only 190 as a total. Am I doing something wrong?
Dim ary() As Variant
For x = 1 To 200
ReDim Preserve ary(x)
V = Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary)
Selection.MoveRight wdCharacter, 1, wdMove
w = Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary)
If w - V = 0 Then GoTo there
ary(x) = w - V
Next
there:
Selection.EndKey wdStory
For T = 1 To UBound(ary())
nb = nb + ary(T)
Next
Selection.TypeText (nb) 'nb = 190 ?
I'm using Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary) to calculate the width of a line in a 2010 Word document.
A line in a 8.5 X 11" document measures 457.9 across from the left to right margins if I place the IP between the second to last character and the last. (If I put the IP after the last it returns 0.
6.5 x 72 = 468 so I guess the measurement is in points, but off by a few, even including the last letter (5.0+points).
Oddly when I tally all the character widths (of a string of numbers without blank spaces) in a 6.5" line using an array using the code below I get only 190 as a total. Am I doing something wrong?
Dim ary() As Variant
For x = 1 To 200
ReDim Preserve ary(x)
V = Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary)
Selection.MoveRight wdCharacter, 1, wdMove
w = Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary)
If w - V = 0 Then GoTo there
ary(x) = w - V
Next
there:
Selection.EndKey wdStory
For T = 1 To UBound(ary())
nb = nb + ary(T)
Next
Selection.TypeText (nb) 'nb = 190 ?
Last edited: