Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1121
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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