Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Fri, 14 Mar 2008 13:31:36 -0700 (PDT),    group: microsoft.public.word.vba.beginners        back       


Measuring the Width of Text with VBA?   
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
date: Fri, 14 Mar 2008 13:31:36 -0700 (PDT)   author:   unknown

Re: Measuring the Width of Text with VBA?   
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.
date: Fri, 14 Mar 2008 14:16:09 -0700 (PDT)   author:   unknown

Re: Measuring the Width of Text with VBA?   
Aha!  I think

ActiveDocument.Range.Characters.Last.Select
MsgBox Selection.Information(wdVerticalPositionRelativeToPage)

might do the trick!
date: Fri, 14 Mar 2008 14:38:39 -0700 (PDT)   author:   unknown

Re: Measuring the Width of Text with VBA?   
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
date: Fri, 14 Mar 2008 23:08:48 +0100   author:   Helmut Weber

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us