Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    May 2001
    Location
    Berkeley, California, USA
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    find two different words (03 SP1)

    Is it possible to do a search for all occurrences of two different words. In this case I wish to find all occurrences of "must" or "shall"?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find two different words (03 SP1)

    Not using Edit | Find. You'd have to write your own search routine in VBA.

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: find two different words (03 SP1)

    The closest you could get with this as a single pass search would be to use wildcards and search for something like '<[ms][ushal]{2,3}[tl]>'
    This will give you some hits you don't want such as mast but it is probably the closest you can get with Word's built-in search.

    When you find these requirements keywords what are you planning to do with the result? Do you need to also find 'should' and 'will'?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    3 Star Lounger
    Join Date
    May 2001
    Location
    Berkeley, California, USA
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find two different words (03 SP1)

    What I did was to search for all occurrences of "must" and checked the "Highlight all items found" Then I highlighted them, then I searched for all occurrences of "shall" and highlighted those. That worked for my purposes.

    To answer your question:
    I have a large legal document, a Request for Proposals. It contains many requierments for bidders and for contractors who might end up recieving an award. Some requierments are desirable and others are manditory. I needed to isolate the subset of requierments that were mandatory. All mandatory requierments use either the word "must" or "shall".
    After they were all isolated I deleted those sentence without any highlighted words.

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: find two different words (03 SP1)

    An alternate way of doing this is to capture each paragraph that contains a requirement (to get some more context for the requirement. This macro attempts to do much the same thing as you have done but results in the captured clauses entire paragraph being linked back to the source document. Perhaps a modification to this macro will give you more functionality than what you are currently getting.
    <pre>Sub CaptureRequirements()
    Dim aDoc As Document, aNewDoc As Document, x As Integer
    Dim sPath As String, iWord As Integer
    Dim aWord
    Set aDoc = ActiveDocument
    Set aNewDoc = Documents.Add
    sPath = aDoc.FullName
    x = 0
    Dim aPar As Paragraph
    For Each aPar In aDoc.Paragraphs
    'fast but gets some false hits eg willow
    If InStr(aPar.Range.Text, "will") Or InStr(aPar.Range.Text, "shall") Then
    iWord = 1
    For Each aWord In aPar.Range.Words 'less false hits but slower
    If Trim(aWord) = "will" Or Trim(aWord) = "shall" Then
    'no exit in for loop so multiple hits in para gives multiple paras in result
    x = x + 1
    aDoc.Bookmarks.Add "Req" & x, aPar.Range 'adds bookmark in source
    aNewDoc.Content.InsertAfter aPar.Range.Text
    'hyperlink only works if source doc has been saved
    aNewDoc.Hyperlinks.Add Address:=sPath, SubAddress:="Req" & x, _
    Anchor:=aNewDoc.Paragraphs(aNewDoc.Paragraphs.Coun t - 1).Range.Words(iWord)
    aNewDoc.Paragraphs(aNewDoc.Paragraphs.Count - 1).Range.Words(iWord). _
    HighlightColorIndex = wdYellow
    End If
    iWord = iWord + 1
    Next aWord
    End If
    Next aPar
    Set aDoc = Nothing
    Set aNewDoc = Nothing
    End Sub</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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