Hi Gerry:
I understand that there are some words that are being replaced with the same word and it is intentional. This is so that the original word is not overwritten with the inappropriate word, it will just get highlighted. Since I needed to use the same word for the replacement but highlight it, I used this technique. In the example that I provided I did use the "Trial" and "Trail" option only for code check purposes. It is not used in runtime. However, there are some spellings that are replaced with the correct spellings, for eg. judgement vs. judgment (since judgement is a british spelling of the word and our firm is in the US). These words are highlighted with red to make it stand out, since it is a fatal error if british spellings are found by the client.
Joost:
That tweak was marvellous. With your help, I've now made the following edit to the code, which still needs a bit of a nudge. I'm having a difficulty in setting the highlight color from the variable.
the code looks like this now:
[VBA]
For j = 1 To i
If MyList(j, 0) = "*" Then
ColorUse = MyList(j, 1)
j = j + 1
End If
Options.DefaultHighlightColorIndex = ColorUse ' This is where I need help
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
With Selection.Find
.Text = MyList(j, 0)
.Replacement.Text = MyList(j, 1)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
[/VBA]
It shows me a type mismatch error. I know that wdDarkRed and the other color codes are VBA standard, however, can't it be passed thru a variable? If it can be, is there any other method of passing these codes to that line?
Thanks for all the efforts guys...