View Single Post
 
Old 09-08-2016, 01:01 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
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 ofgmayor has much to be proud of
Default

You can extract them individually, which begs the question - what do you want to do with these strings having extracted them?

'Contains' upper case characters or 'comprises' upper case characters?

The following assumes only upper case characters & space (no punctuation)


Code:
Sub Macro1()
Dim oRng As Range
Dim oPara As Paragraph
Dim sText As String
    For Each oPara In ActiveDocument.Paragraphs
        Set oRng = oPara.Range
        With oRng.Find
            Do While .Execute(FindText:="^t[A-Z ]{1,}^t", MatchWildcards:=True)
                If oRng.InRange(oPara.Range) Then
                    sText = Replace(oRng.Text, Chr(9), "")
                    'do something with stext e.g.
                    MsgBox sText
                End If
                oRng.Collapse 0
            Loop
        End With
    Next oPara
lbl_Exit:
    Set oRng = Nothing
    Set oPara = Nothing
    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