Me again!
Is there any easy way to measure the width of, e.g., a Heading Two
using VBA. (As opposed to measuring the character count, which is
easy but unreliable).
Basically I want to know if any given heading occupies one, two, or
three lines of the page...
Cheers,
Matthew
osirun@gmail.com - 14 Mar 2008 22:16 GMT
Another idea - is there any way I can tinker with
ActiveDocument.Range.Characters.Last.Information(wdVerticalPositionRelativeToPage)
so that it shows me how far down the page the last character of a
Heading Two might be?
At the moment it doesn't seem to work - or at least I get the same
value for every heading I try.
osirun@gmail.com - 14 Mar 2008 22:38 GMT
Aha! I think
ActiveDocument.Range.Characters.Last.Select
MsgBox Selection.Information(wdVerticalPositionRelativeToPage)
might do the trick!
Helmut Weber - 14 Mar 2008 23:08 GMT
Hi,
like that:
Sub Test7()
Dim rTmp As Range
Set rTmp = ActiveDocument.Range
With rTmp.Find
.Style = "Heading 1"
While .Execute
MsgBox rTmp.ComputeStatistics(wdStatisticLines)
MsgBox
rTmp.Characters.Last.Information(wdVerticalPositionRelativeToPage)
Wend
End With
End Sub
Beware of linebreaks by the newsreader.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP