Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Use Find without selecting (2002)

    How do I use Find in a macro without having the text found selected, or turning off the selection and positioning the cursor at the end of the selected text?

    Sorry, my brain is mush today, I know this is a simple question.

  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: Use Find without selecting (2002)

    To avoid affecting the Selection, use a Range.Find instead.

    I don't follow the second part of your question, sorry. Is that what you want to do or what you want to avoid?

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Use Find without selecting (2002)

    See my brain really is mush. I just want a simple macro which finds then next 2 paragraph marks in a row (double space), then moves to the end of that line. This helps my users move up and down between headings in a document.

  4. #4
    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: Use Find without selecting (2002)

    Well, it's Saturday. I'd record a Find for ^p^p and then use Selection.Collapse wdCollapseEnd to get closer to position. Not sure if that gets you all the way there, or you need to Selection.MoveRight wdCharacter or Selection.MoveDown wdParagraph to the beginning of the next paragraph, too.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use Find without selecting (2002)

    Hi Jeanie,

    I think this is what you're looking for:

    <pre>Sub MoveToNextHeading()
    With Selection
    With .Find
    .ClearFormatting
    .Text = "^p^p"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With

    If (.Find.Execute) Then
    .Collapse wdCollapseEnd
    .MoveEndUntil cset:=Chr(13)
    .Collapse wdCollapseEnd
    End If
    End With
    End Sub
    </pre>


    HTH,

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use Find without selecting (2002)

    Hi Jeanie:
    Why not just a macro that finds the next heading? Or you could create a macro that sets the browsenext command to headings & then finds the next heading. (Of course, there's always the Document Map or Outline View). <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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