Article ID: 183641
Article Last Modified on 6/17/2005
Sub LineByLine()
Dim x As Integer
Dim sWord As String
' Move the insertion point to the beginning of the document.
Selection.HomeKey Unit:=wdStory, Extend:=wdMove
' Loop number of lines in document.
x = ActiveDocument.BuiltInDocumentProperties("NUMBER OF LINES")
For i = 1 To x
' Select a line.
ActiveDocument.Bookmarks("\LINE").Select
' Display line number.
MsgBox "Line: " & i
' Move to next line.
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
Next i
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbhowto kbmacroexample KB183641