View Single Post
 
Old 03-27-2015, 10:50 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
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

It seems fairly straightforward. How about:

Code:
Sub ExtractText()
'Seb AllenThursday, 26 March 2015 at 16:13 UTC
Dim oSource As Document
Dim oTarget As Document
Dim oRng As Range
    Set oSource = ActiveDocument
    'Create a document to hold the extracts
    Set oTarget = Documents.Add
    'replace line breaks with paragraph breaks
    Set oRng = oSource.Range
    oRng.Text = Replace(oRng.Text, Chr(11), Chr(13))
    With oRng.Find
        'Find the times
        Do While .Execute(FindText:="at [0-9]{2}:[0-9]{2} UTC", _
                          MatchWildcards:=True)
            'Copy the paragraph containing the found time to the new document
            oTarget.Range.InsertAfter oRng.Paragraphs(1).Range.Text
            oRng.Collapse 0
            DoEvents
        Loop
    End With
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