View Single Post
Old 06-05-2013, 07:44 AM
String String is offline Windows XP Office 2007
Join Date: Jun 2013
Posts: 3
String is on a distinguished road


This is the macro code I am using to highlight each separate word. Its a very lightly modified code I found on these forums.

Sub HiLightList()
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "yellow,green,dog,horse"
For i = 0 To UBound(Split(StrFnd, ","))
  Set Rng = ActiveDocument.Range
  With Rng.Find
    .Text = Split(StrFnd, ",")(i)
    .Replacement.Highlight = True
    .Replacement.Text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
  End With
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
So once its found and highlighted these words, I need it to wrap an HTML tag around them all.

Reply With Quote