mpeterson,
1) It looks like I forgot to add "Set oRngBox = oSrchRng.Duplicate" immediately after "Set oSrchRng = Set oSrchRng = oRng.Paragraphs(4).Range
2) This is a problem. It should be failing on the line .Text = strFind because the string length of that parameter is limited to 255 characters. I think the best I could do gratis is hightlight those instances and hopefully there are not a lot of them. You can then go back and add the closing tag.
3. Sure
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
Dim strFind As String
Dim oRng As Word.Range
Dim oRngBox As Word.Range
Dim oSrchRng As Word.Range
Dim bCorrect As Boolean, bTooLong As Boolean
Set oRng = ActiveDocument.Range
oRng.Collapse wdCollapseStart
Do
Do
On Error Resume Next
oRng.MoveEnd wdParagraph
If Err.Number <> 0 Then Exit Do
Loop Until oRng.Characters.Last.Next = Chr(13)
On Error GoTo 0
For lngIndex = 5 To oRng.Paragraphs.Count
bCorrect = False
bTooLong = False
strFind = oRng.Paragraphs(lngIndex).Range.Text
If Left(strFind, 1) = "*" Then bCorrect = True
strFind = Right(strFind, Len(strFind) - InStr(strFind, ".") - 1)
strFind = Left(strFind, Len(strFind) - 1)
Set oSrchRng = oRng.Paragraphs(3).Range
Set oRngBox = oSrchRng.Duplicate
Selection.Find.ClearFormatting
With oSrchRng.Find
If Len(strFind) > 255 Then bTooLong = True
If Not bTooLong Then
.Text = strFind
While .Execute
If oSrchRng.InRange(oRngBox) Then
With oSrchRng
If oSrchRng.Characters.Last.Next = "." Then oSrchRng.MoveEnd wdCharacter, 1
If bCorrect Then
.InsertBefore "<font color = ""#1A06FB"">"
Else
.InsertBefore "<font color = ""#008000"">"
End If
.InsertAfter "</font>"
.Collapse wdCollapseEnd
End With
End If
Wend
Else
.Text = Left(strFind, 255)
While .Execute
If oSrchRng.InRange(oRngBox) Then
With oSrchRng
If bCorrect Then
.InsertBefore "<font color = ""#1A06FB"">"
Else
.InsertBefore "<font color = ""#008000"">"
End If
.HighlightColorIndex = wdYellow
.Collapse wdCollapseEnd
End With
End If
Wend
End If
End With
Set oSrchRng = oRng.Paragraphs(4).Range
Set oRngBox = oSrchRng.Duplicate
With oSrchRng.Find
If Len(strFind) > 255 Then bTooLong = True
If Not bTooLong Then
.Text = strFind
While .Execute
If oSrchRng.InRange(oRngBox) Then
With oSrchRng
If oSrchRng.Characters.Last.Next = "." Then oSrchRng.MoveEnd wdCharacter, 1
If bCorrect Then
.InsertBefore "<font color = ""#1A06FB"">"
Else
.InsertBefore "<font color = ""#008000"">"
End If
.InsertAfter "</font>"
.Collapse wdCollapseEnd
End With
End If
Wend
Else
.Text = Left(strFind, 255)
While .Execute
If oSrchRng.InRange(oRngBox) Then
With oSrchRng
If bCorrect Then
.InsertBefore "<font color = ""#1A06FB"">"
Else
.InsertBefore "<font color = ""#008000"">"
End If
.HighlightColorIndex = wdYellow
.Collapse wdCollapseEnd
End With
End If
Wend
End If
End With
Next lngIndex
oRng.Collapse wdCollapseEnd
oRng.MoveStart wdParagraph, 1
Loop Until oRng.End = ActiveDocument.Range.End - 1
End Sub