Finding the line number that the cursor is on

B

bbacklin

Hi,

I need VBA code to determine what the line number is based on th
location of the cursor. I also need the code for determining the lin
number(s) of a bookmark. I know that I can find the character positio
with:

Selection.Range.Start

But what I need is the line number. In the normal view as you type yo
can see the current position of the cursor in Line, Column, Page #, et
on the bottom of the window. Are these values accessable in VB
anywhere?

Bra
 
H

Helmut Weber

Hi,

MsgBox Selection.Information(wdFirstCharacterLineNumber)

You may have to switch views beforehand, like

ActiveWindow.View = wdNormalView
ActiveWindow.View = wdPrintView

or the other way round,
as Selection.Information(wdFirstCharacterLineNumber)
may otherwise return -1.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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