View Single Post
 
Old 09-09-2016, 12:41 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

If you want the whole paragraph then it is opara
Code:
Sub Macro2()
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:="010^t")
                If oRng.start = oPara.Range.start Then
                    sText = oPara.Range
                    '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
alternatively
Code:
Sub Macro3()
Dim oRng As Range
Dim sText As String
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="010^t")
            If oRng.start = oRng.Paragraphs(1).Range.start Then
                sText = oRng.Paragraphs(1).Range.Text
                'do something with stext e.g.
                MsgBox sText
            End If
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = 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