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 / January 2006

Tip: Looking for answers? Try searching our database.

Row cursor position in Word via VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kenshiro2000@libero.it - 19 Jan 2006 15:45 GMT
Hi,

How can I get row number at the Cursor position in VBA Word XP?

Thanks

ken
Helmut Weber - 19 Jan 2006 16:05 GMT
Hi,

you're probably meaning the line number on a page.

MsgBox Selection.Information(wdFirstCharacterLineNumber)

You may have to switch views beforehand.
Normal to printlayout and back or vice versa.

Otherwise, the msgbox may return -1.

Signature

Gruß

Helmut Weber, MVP WordVBA

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

kenshiro2000@libero.it - 20 Jan 2006 14:32 GMT
Thanks so much.....

But Now I have another problem....

wdFirstCharacterLineNumber return the character at the right of
collapsed Selection....so How can I know when the return is the Line
number and when is the character code????

This is a strange behavior!!!

Thanks

Helmut Weber ha scritto:

> Hi,
>
[quoted text clipped - 14 lines]
> "red.sys" & chr$(64) & "t-online.de"
> Win XP, Office 2003
Helmut Weber - 20 Jan 2006 21:12 GMT
Hi,

>wdFirstCharacterLineNumber return the character at the right of
>collapsed Selection..

hmm...

indeed, very strange.
Never heard this before, and hard to believe.

Show us your code.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

kenshiro2000@libero.it - 25 Jan 2006 09:29 GMT
This is from the Help:

"wdFirstCharacterLineNumber Returns the character position of the first
character in the specified selection or range. If the selection or
range is collapsed, the character number immediately to the right of
the range or selection is returned (this is the same as the character
line number displayed in the status bar after "Ln")."

Bye
Helmut Weber - 25 Jan 2006 15:56 GMT
Hi,

>If the selection or range is collapsed, the character number immediately
>to the right of the range or selection is returned

this is simply wrong.

It should read as:
"The line number where the character immediately to the right is..."

And this wrong, too.

Because, if you move the insertion point to the end of a line,
e.g. Selection.EndKey Unit:=wdLine
where there is no character at all immediately to the right,
you still get the line the insertion point is in.

If one thinks of "immediately to the right" as equal to "next",
then the help is wrong again.

Happens.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

kenshiro2000 - 25 Jan 2006 17:15 GMT
I have tested this and it is TRUE :-)

In a blank line, the System.Information return vbCr not the row number.
Doug Robbins - Word MVP - 26 Jan 2006 05:20 GMT
MsgBox Selection.Information(wdFirstCharacterLineNumber)

displays the line number for me regardless of the state of the selection.

Signature

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

>I have tested this and it is TRUE :-)
>
> In a blank line, the System.Information return vbCr not the row number.
 
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.