Solved

Looping in Word VBA to the End of Document

Posted on 1998-12-10
3
1,111 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

828 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