View Single Post
 
Old 07-16-2019, 09:44 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

As someone who has, so far successfully, been treated for prostate cancer over the past few years, this is one cause I am happy to assist with, however without access to examples of the source documents and a list of what you want to search for and expect to find in relation to those texts, it is difficult to provide that assistance. However the following will find words or phrases from a list followed by a space and a number, which might help get you started.

I don't have the Mac version of Word, but it should still work.
Code:
Sub Macro1()
Dim vFindText As Variant
Dim oRng As Range
Dim oColl As Collection
Dim oSource As Document, oTarget As Document
Dim i As Long, j As Integer
    Set oSource = ActiveDocument
    Set oTarget = Documents.Add
    Set oColl = New Collection
    vFindText = Array("SHIM", "WORD2", "WORD3")    'list the words or phrases to find
    For i = 0 To UBound(vFindText)
        Set oRng = oSource.Range
        With oRng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            Do While .Execute(FindText:=vFindText(i) & "[ .0-9]{1,}", _
                              MatchWildcards:=True)
                oTarget.Range.InsertAfter oRng.Text & vbCr
                oRng.Collapse wdCollapseEnd
            Loop
        End With
    Next i
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote