Article ID: 176238
Article Last Modified on 1/22/2007
Sub LineByLine()
Dim x As Integer
Dim fdWord 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:
173707 OFF97: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vba vbe vb loop
Keywords: kbdtacode kbhowto kbmacroexample kbprogramming KB176238