View Single Post
 
Old 01-31-2019, 01:17 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

It is just a matter of rearranging and a few minor changes.


Code:
Sub ScratchMacro()
 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 01/31/2019
Dim oRng As Range
Dim arrFind() As String
Dim lngIndex As Long
Dim strContent
Dim oThisDoc As Document
Dim oDoc As Document
  
  Set oThisDoc = ActiveDocument
  arrFind = Split("1945,1946,1947", ",")
  Set oRng = ActiveDocument.Range
  strContent = vbNullString
  For lngIndex = 0 To UBound(arrFind)
    Set oRng = ActiveDocument.Range
    With oRng.Find
      .ClearFormatting
      .Text = arrFind(lngIndex)
      .Forward = True
      .Wrap = wdFindStop
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      Do While .Execute
        strContent = strContent & oRng.Paragraphs(1).Range.Text & vbCr
      Loop
    End With
  Next lngIndex
  If strContent <> vbNullString Then
     Set oDoc = Documents.Add(, , wdNewBlankDocument)
     oDoc.Range.Text = strContent
     oDoc.Activate
  End If
lbl_Exit:
  Exit Sub
End Sub

I do. You can use any of the PayPal donate links on the various webpages. Thank you.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote