Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Dec 2001
    Location
    Santa Barbara, California, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wild Card Search to find section of line, know start and end, ignore middle

    I'm trying to find all of the lines in a large word file containing "Operator ID * Terminal ID" , in lines of the form below, ignoring the EMPLOYNAME ENAME and # portion, since that changes. I would think 'Operator ID*Terminal ID' would do it, but it finds nothing, wildcards are turned on. Been testing it in Word 2010 find box, but the final item will be used in VBA to select the section and capture the "E NAME".

    So anyone know the syntax for this one?

    8674 2 EMPNAME 2/21/2013 10:28:16 AM 0.00 Operator ID EMPLOYNAME E NAME Terminal ID #

    Thanks.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,515
    Thanks
    3
    Thanked 143 Times in 136 Posts
    There must be something strange going on for your machine because that search string works for me when the wildcards are turned on.

    Are there any tracked revisions in the document that might be causing the problem?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,899
    Thanks
    0
    Thanked 188 Times in 172 Posts
    The code also wouldn't work if:
    • the string contains hard spaces but you're specifying soft ones; and/or
    • you've previously specified a particular format for a Find, haven't cleared that and the text to be found isn't in that format.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #4
    Lounger
    Join Date
    Dec 2001
    Location
    Santa Barbara, California, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,
    No none of those. I've got word 2003,2007,2010 on different machines, I'll try it on those ans see what happens, plus VBA where I can be sure every other search option is off.

    Steve

  6. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,899
    Thanks
    0
    Thanked 188 Times in 172 Posts
    Are you sure you have the 'use wildcards' option checked? You might also try:
    Operator?ID[!^13^l]@Terminal?ID

    FWIW, the following works for me:
    Code:
    Sub Demo()
    Application.ScreenUpdating = False
    Dim StrOut As String
    With ActiveDocument.Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "Operator?ID[!^13^l]@Terminal?ID"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
        .Execute
      End With
      Do While .Find.Found
        StrOut = StrOut & Mid(.Text, 13, InStrRev(.Text, "Terminal") - 13) & vbCr
        .Collapse wdCollapseEnd
        .Find.Execute
      Loop
    End With
    Application.ScreenUpdating = True
    MsgBox StrOut
    End Sub
    Last edited by macropod; 2014-01-21 at 16:09. Reason: Code revision
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #6
    Lounger
    Join Date
    Dec 2001
    Location
    Santa Barbara, California, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes that works.. I got the original Operator ID*Terminal ID to work by changing it to
    Operator ID*Terminal ID*^13. Just noticed that NOW the original Operator ID*Terminal ID search now works as it should have in the first place. Still don't see what I could have changed, but that's programming.
    Thanks
    Steve

Posting Permissions

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