Word How to get 'current line number' in Word VBA

Joined
Jan 17, 2012
Messages
4
Reaction score
0
Environment is Word 2010, and I'm trying to get the number of lines in various sections. Start by getting the line number of the start of the section:
Code:
Sub FormatSection(s As Long)

Dim MySection As Section

Dim ProcType As String
Dim ProcName As String
Dim SectionStart As Long
Dim SectionEnd As Long
Dim TestString As String

Dim SectionLineStart As Long
Dim SectionLineEnd As Long
Dim SectionLineLength As Long

Set MySection = ActiveDocument.Sections(s)
MySection.Range.Select
Debug.Print "Section"; s; " starts in line"; Selection.Information(wdFirstCharacterLineNumber)
Rather than giving me the line number in the document, the Selection.information returns a consistent value of 1

Well this is true, of course!
The line number within the section of the first character in the section is line 1. (If it weren't I'd be worried, although I guess 0 might be acceptable).

However, I want the line number within the document. Can anybody help? I'm most emphatically not going to iterate from the beginning of the document until I happen to get the beginning of a section.

This can not be the first time someone has wanted this piece of information?

Tony
 
Back
Top