Solved

Looping in Word VBA to the End of Document

Posted on 1998-12-10
3
1,109 Views
Last Modified: 2009-12-16
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
Comment
Question by:lesterm
3 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 1615001
Hi,

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

Accepted Solution

by:
frazer earned 50 total points
ID: 1615002
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
 

Author Comment

by:lesterm
ID: 1615003
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question