View Single Post
 
Old 02-06-2017, 07:47 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub FindTextBetweenWords()
Dim oRng As Word.Range, oPasteRng As Range
Dim oDoc As Document, oTargetDoc As Document
  Set oDoc = ActiveDocument
  Set oTargetDoc = Documents.Add
  oDoc.Activate
  Set oRng = oDoc.Range
  With oRng.Find
    .ClearFormatting
    .Wrap = wdFindStop
    .MatchCase = False
    .Text = "References:*Working paper No"
    .MatchWildcards = True
    While .Execute
       oRng.Select
       Selection.EndKey Unit:=wdLine, Extend:=wdExtend
       Selection.Copy
       Set oPasteRng = oTargetDoc.Range
       oPasteRng.Collapse wdCollapseEnd
       oPasteRng.Paste
       oRng.Collapse wdCollapseEnd
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote