Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    loop until end of file (2000 w/o SR)

    What command do I use to make a macro repeat until it reaches the end of the document (EOF)?? Thanks.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: loop until end of file (2000 w/o SR)

    If you are moving the insertion point, then the end is signified by

    Selection.Start = ActiveDocument.Characters.Count - 1

    There are other ways, but this is the one I used last. So, you could do this:

    While Selection.Start < ActiveDocument.Characters.Count - 1
    'do stuff
    'move insertion point
    Wend

    or if it's more complicated and you need to do some things but not others...

    Do
    'some things
    If Selection.Start = ActiveDocument.Characters.Count - 1 Then Exit Do
    'do others
    'move insertion point
    Loop

    if it's a find/replace, by any chance, there's a different and better way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •