position of a selection

V

vhoward

hi,

i use word2003 and vba

i need to determine the localization of a selection in mm or inches, how can
i do that ?

thanks in advance
 
D

Doug Robbins - Word MVP

Selection.Information (wdHorizontalPositionRelativeToPage)
Selection.Information (wdVerticalPositionRelativeToPage)


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
H

Helmut Weber

Hi,

like this and in many other ways:

Sub Test00143()
Dim x1 As Single
Dim x2 As Single
Dim y1 As Single
Dim y2 As Single
x1 = selection.Information(wdHorizontalPositionRelativeToPage)
selection.Collapse Direction:=wdCollapseEnd
x2 = selection.Information(wdHorizontalPositionRelativeToPage)
MsgBox PointsToCentimeters(x2 - x1)
y1 = selection.Information(wdVerticalPositionRelativeToPage)
selection.Collapse Direction:=wdCollapseEnd
y2 = selection.Information(wdVerticalPositionRelativeToPage)
MsgBox PointsToCentimeters(y2 - 11)
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Helmut Weber

Whereby,

after having collapsed the selection,
the positions you get may not be very informative.

HW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top