Word VBA, Get Current Line Number

Using the code below you can get the current line the cursor is on:

Sub main()
Dim intCurrentLine As Integer
intCurrentLine = _
    Selection.Range.Information(wdFirstCharacterLineNumber)
MsgBox (intCurrentLine)
End Sub

Note: The current page number is relative to the page. That means the line number starts from “1” at the start of each page.

In the figure below the cursor is located at line 26:

Word VBA, Get Current line
Result after running the code:

Result, Word VBA, Get Current Line

See also:

If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website  www.software-solutions-online.com

One thought on “Word VBA, Get Current Line Number”

Leave a Reply

Your email address will not be published. Required fields are marked *