Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    New York, USA
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Section Find Loop

    I am stuck trying to exit a loop. I want to use Find to delete a certain style in Section(1) but find just keeps on going past the section I want to stay with. Below is some of the code without any exit code attempts.

    Set myPage = ActiveDocument.Sections(1).Range

    idx = 1
    With myPage.Find
    .ClearFormatting
    .Style = ActiveDocument.Styles("Envelope Address")
    Do While .Execute(FindText:="", Forward:=True, Format:=True) = True
    For Each Paragraph In .Parent.Paragraphs
    Paragraph.Range.Select
    AddDel(idx) = Selection.Text
    idx = idx + 1
    Next
    Loop
    End With

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Section Find Loop

    Thom,

    Try something like the following (sorry don't have time to test it right now):

    .Execute FindText:="", Forward:=True, Format:=True, Wrap:=wdFindStop
    Do While .Found
    For Each Paragraph In .Parent.Paragraphs
    Paragraph.Range.Select
    AddDel(idx) = Selection.Text
    idx = idx + 1
    Next
    Loop

    Gary

Posting Permissions

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