• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1120
  • Last Modified:

Looping in Word VBA to the End of Document

I need to know how to write a loop that will execute until it reaches the End of the Document.  Something like the following: "Do while Not EOF".  If that is not possible I would like to know how to at least count the lines in the document?
0
lesterm
Asked:
lesterm
1 Solution
 
bruintjeCommented:
Hi,

You can use the Word.wdWordDialog with the constant wdDialogToolsWordCount. This function will return your lines, paragraphs etc.
0
 
frazerCommented:
Hi,

This will step through the document one character at a time.....

Sub StepThrough()
    Dim a&
    For a = 0 To ActiveDocument.Characters.Count
        MsgBox ActiveDocument.Range(a, a + 1)
    Next
End Sub


Hope this helps

Frazer
0
 
lestermAuthor Commented:
Thanks for the answer, but I was wanting to know how to count line by line or execute a command until the end of the file.  However, I do like the subroutine that you sent me.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now