Getting the current Sentence position

I have the following code.

Dim wrdApp As Word.Application
Dim appWord As Word.Document

wrdApp.Selection.GoTo wdGoToLine, wdGoToFirst  

and i open appWord with the

With wrdapp.Selection.Find
    .Forward = True
    .Wrap = wdFindStop
    .Text = "$"
   End With

When it finds the occurance of the $, i need to findout what line number it is on, how can i do that?

appword.Sentences(10) is line 10 (the line number i want)
but i can't find anything that will return to me that current position or line number.

Who is Participating?
damion69Connect With a Mentor Commented:
Ok... Here is another piece of code that does that...
masterofhisdomainAuthor Commented:
Unfortunately, that is only for controls, the API has to have a handle in order to find the position based of the cursor position, which is not going to work in my case.

This application i am building has no forms or controls.

I have opened the word document, and have found the character i am looking for, now i just need what line number it is on.

Thanks tho, it will bue useful in the future.

Any other ideas?
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

What do you mean by line number?

Do you need the postition relative to the page or the start of the document/story?
masterofthisdomain, I am more than happy to be proved wrong in the following statement but as far as I am aware there is no method within Word to access the Line/Column position of a character. The information that is displayed within the status bar has to be calculated somehow but this is not apparently available to mere mortals using the application.
well damion69, not quite. This code simply retrieves the number of lines in total in a document using an antiquated and non-recommended method so it unfortunately not going to help in this situation.
Word will easily tell you what line the cursor is on, but the line number is relative to the page:

Also, there is a method that will tell you how many total lines there are in the document:

I haven't found a method or property that will tell you the line number relative to the start of the story or document.

What are you trying to do that you need this line number data?
masterofhisdomainAuthor Commented:
This is what i was looking for, it led to the answer.  Version 6 uses a different way of doing it.

I ended up adding this to get the current line

Dim Rc as integer

Rc = wrdApp.Selection.Information(wdFirstCharacterLineNumber) - 1

Using the Word objects, when i saw you could do appword.sentences(13) to get line 13 , i knew there had to be a way to get to the current sentence when coming back from a find.  Thank You.
masterofhisdomainAuthor Commented:
Thanks aikimark for your answer, i did not refresh after getting damion69s answer, but after scanning the help file with his answer, found the Info method, and had tried it before, but either missed the line number one or discounted it from being what i was looking for.

I need the line number, because from the first find on, i will be accessing each sentence seperately to do check to see if the line gets added to an array or that sentence sent to a file.

Thanks for all your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.