Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Finding the line number that the cursor is on

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bbacklin - 03 Feb 2006 19:14 GMT
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
Helmut Weber - 03 Feb 2006 20:14 GMT
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.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

bbacklin - 04 Feb 2006 01:39 GMT
Hi,

Thanks for your help.  That is the solution.

Bra
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.