Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 7/13/2017
Dim lngParts As Long
Dim oRng1 As Range, oRng2 As Range, oRng3 As Range
Dim lngIndex As Long
Dim strDelim As String
Dim oDoc As Document
strDelim = "Aziylut"
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
lngParts = UBound(Split(oRng1.Text, strDelim)) + 1
lngIndex = 1
While lngIndex <= lngParts
With oRng1.Find
.Text = strDelim
If .Execute Then
If lngIndex = 1 Then
Set oRng3 = oRng1
oRng3.End = oRng1.Start
oRng3.Start = ActiveDocument.Range.Start
Else
oRng2.Start = oRng1.End
With oRng2.Find
.Text = strDelim
If .Execute Then
Set oRng3 = oRng1
oRng3.Start = oRng1.End '+ 1
oRng3.End = oRng2.Start
Else
oRng3.Start = oRng1.End '+ 1
oRng3.End = ActiveDocument.Range.End
End If
End With
End If
oRng3.Copy
oRng1.Collapse wdCollapseEnd
oRng2.Collapse wdCollapseEnd
End If
End With
Set oDoc = Documents.Add(ActiveDocument.AttachedTemplate.FullName)
oDoc.Content.Delete 'Strip template boiler plate text
With Selection
.PasteAndFormat (wdFormatOriginalFormatting)
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
oDoc.UpdateStylesOnOpen = False
'I'll leave it to you to figure out how to save it.
X = X + 1
ActiveDocument.SaveAs2 ThisDocument.Path & "\" & Notes & Format(X, "000")
oDoc.Close wdDoNotSaveChanges
lngIndex = lngIndex + 1
Wend
End Sub
Not going to Lie Greg, I cant thank you enough. I've gone from a novice who can read no VBA, so actually understanding what is happening and why its happening...in less than 5 days. I really appreciate all of your help!