Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Omaha, Nebraska
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Case Insensitive find w/ wildcards

    I'm working with an existing VBA application that the users are requesting adding the capability of using wildcards in their find/replace search. I can change the following code to allow wildcards...but the search becomes case sensitive. Is there a way to avoid this?

    Private Sub SetSearchCriteria()
    With Selection.Find
    .ClearFormatting
    .Replacement.Text = vbNullString
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False --> True allows wildcards
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    End Sub

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

    Re: Case Insensitive find w/ wildcards

    Hi bitram:

    I'm not a VBA expert, but I can tell you that when you do a search using Wildcards, the match case checkbox becomes dimmed. If you want to search for both upper & lowercase, you use an expression such as, [a-zA-Z]. This searches for both upper & lower.

    Hope this helps.

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Location
    Omaha, Nebraska
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Case Insensitive find w/ wildcards

    Thanks for the quick response Phil!

    Using your example... If I was searching for the word 'string', how would I implement that?...
    - in the find box type [a-zA-Z]string - ??
    - in the find box type [a-zA-Z]"string" - ??

    Michael

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

    Re: Case Insensitive find w/ wildcards

    Hi Michael:

    Well, that's why I said I wasn't a VBA expert. I know how to do a Find/Replace, but I don't know what commands would execute what you want.

    If you were not using VBA, but using Find/Replace & wanted to find the word "string", regardless of case, you wouldn't tick "Use Wildcards".

    But if you wanted to do it using the wildcard search engine, you would use:
    [sS][Tt][rR][Ii][nN][Gg]

  5. #5
    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: Case Insensitive find w/ wildcards

    There is this thing in VBScript called the RegExp (regular expressions) object that lets you do case insensitive find and replace. I posted a sample procedure <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=25371>here</A>. As noted in my additional comments on the other message, it's not so hot for changes in a document because the formatting gets whacked.

    Another problem with using this kind of thing interactively is that the syntax is different than Word's native wildcard replace. For example, you have to put a before a . or it is interpreted as "one character." The list goes on. If you do end up coding this, I'd love to see a copy. I have attached another sample from a more recent project.
    Attached Files Attached Files

Posting Permissions

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