Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Search (VBA/Word/98,2000)

    I have always seen the code for a search activity written in the following form:
    <pre> Selection.Find.ClearFormatting
    With Selection.Find
    .Text = "("
    .Replacement.Text = "^^^^"
    .Forward = False
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute</pre>


    Is there some reason why the .Execute command is not contained within the With snippet?

    TIA
    Regards
    Don

  2. #2
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Search (VBA/Word/98,2000)

    That's the way the code gets produced if you record a macro. I don't think there's any reason not to put the .Execute within the With. (Likewise the .ClearFormatting.)

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Search (VBA/Word/98,2000)

    I once stumbled on a bug, I don't remember which version of Word it was, where putting the .ClearFormatting in the With caused it to behave incorrectly!

    StuartR

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Search (VBA/Word/98,2000)

    Thank you Stuart and St333ve.
    Regards
    Don

Posting Permissions

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