Solved

Looping in Word VBA to the End of Document

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
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…
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…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

708 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now