By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,182 Members | 1,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,182 IT Pros & Developers. It's quick & easy.

stopping a "For Each" loop at EOF

P: n/a
I'm formatting data in a text file using a "For Each aPara" statement
along with a "Next aPara." How do I make the thing stop when it
reaches the end of the file, rather than starting again at the top of
the file and looping forever? Thanks, I'm new at this.

Orin Hargraves
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Orin Hargraves" <or****@carr.org> wrote in message
I'm formatting data in a text file using a "For Each aPara" statement
along with a "Next aPara." How do I make the thing stop when it
reaches the end of the file, rather than starting again at the top of
the file and looping forever? Thanks, I'm new at this.

For each para in WHAT ??

What are you looping through? What is each item?

LFS

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #2

P: n/a
On 11 Dec 2003 08:24:41 -0800, or****@carr.org (Orin Hargraves) wrote:
I'm formatting data in a text file using a "For Each aPara" statement
along with a "Next aPara." How do I make the thing stop when it
reaches the end of the file, rather than starting again at the top of
the file and looping forever? Thanks, I'm new at this.

Orin Hargraves


Type in EOF then press [F1]
Jul 17 '05 #3

P: n/a
This tells us nothing. aPara is not a VB 'thingy', so you're using something
either incorrectly, or that you obtained to wrap certain functionality.
Since we do not have whatever this is, your question provides no
information.

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.
"Orin Hargraves" <or****@carr.org> wrote in message
news:37**************************@posting.google.c om...
: I'm formatting data in a text file using a "For Each aPara" statement
: along with a "Next aPara." How do I make the thing stop when it
: reaches the end of the file, rather than starting again at the top of
: the file and looping forever? Thanks, I'm new at this.
:
: Orin Hargraves
Jul 17 '05 #4

P: n/a
Sorry to be vague. My complete "for each" statement is

For Each aPara In ActiveDocument.Paragraphs

Which iterates a number of editing functions in each record in the
open text file (the records corresponding to paragraphs as far as Word
is concerned). The

Next aPara

statement at the end causes the looping; but I want the loop to stop
at the end of the file, not start over again at the top and do it all
again.

Thanks,
Orin
Jul 17 '05 #5

P: n/a
"Orin Hargraves" <or****@carr.org> wrote
Sorry to be vague. My complete "for each" statement is

For Each aPara In ActiveDocument.Paragraphs

Which iterates a number of editing functions in each record in the
open text file (the records corresponding to paragraphs as far as Word
is concerned). The

Next aPara

statement at the end causes the looping; but I want the loop to stop
at the end of the file, not start over again at the top and do it all
again.

Is that what happens? I don't work with Word like that, but I often
use the For/Each methods. For/Each is designed to loop through the
entire contents 1 time, in every application I have seen it. If you find
it is going back to the top (without you telling it to) then that implementation
is far different than every other example I have seen. Double check your
code (step through it using F8) to be sure you don't accidentally tell it
to start over somewhere....

LFS

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.