Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture line number word is found

Status
Not open for further replies.

behbeh

Programmer
Mar 10, 2001
48
US
Hi!
Does anyone know how to programatically capture the line number (of a Word document that uses Line Numbering) that a specific word is found?

I need to build an AddIn that will display the line number (and page number the line number is on) for every occurence of a specific word in a document.

I can't find an object or property from the Word Object Library that I can use that will give me this information.
[sadeyes]
 
I think what you are looking for is the .Information property of the Range or Selection objects.
BTW, I only found out about this property from this forum a while back.
 
Thanks for the info. I played around with both the Range and Selection objects' Information property, but was unsuccessful. I did, however, try so many things that I finally was able to retrieve the line number. First, I grab the total number of lines in the ActiveDocument.BuiltInProperties("NUMBER OF LINES")and use that as my end value in a For counter Loop (starting at 1). Then I use the Selection.Find, .Text, .Format, .Wrap .Execute and an If statement if .Found. If it is .Found, I just grab the current counter value which is the Line Number the word was found. I'm SURE it it not the most efficient way to get this information but it works!
Thanks again for your input!
[dazed]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top