View Single Post
 
Old 08-05-2022, 01:47 PM
Harvi007 Harvi007 is offline Windows 11 Office 2019
Novice
 
Join Date: Aug 2022
Posts: 11
Harvi007 is on a distinguished road
Cool A potential solution... it works..

So after messing about, and finding bits of code online, i've managed to come up with this...

I hope it helps others looking to do the same thing.
----------------------------------------------------------------------------------------
Sub wordslistChange()

Dim avar As Variant

avar = Split(Replace(ActiveDocument.Range.Text, vbCr, " "))

For i = LBound(avar) To UBound(avar)

i = i + 1

'MsgBox avar(i)

With Selection.Find
.ClearFormatting
.Text = avar(i)
On Error Resume Next
.MatchCase = True
.MatchWholeWord = True
.Replacement.ClearFormatting
.Replacement.Text = avar(i)
.Replacement.Font.Color = wdColorRed 'change colour as required
.Forward = True
.Wrap = Word.WdFindWrap.wdFindContinue
.Execute Replace:=Word.WdReplace.wdReplaceOne
End With

Next i

End Sub
------------------------------------------------------------------------------------------

This basically populates the array and then does the odd even colour change magic.

Have fun people and feel free to mod the code to make it even more efficient.

Thank you

Last edited by Harvi007; 08-05-2022 at 10:32 PM.
Reply With Quote