Hi,
In a word document, I need to find all the occurrences of gender check (capital and small letters); male gender and female gender should be highlighted with different colors. I need 2 buttons, one for gender check and other to remove highlighting.
The following code suited my requirement to some extent
Code:
Sub GenderHighlight()
Dim r As Range
Dim MyList() As String
Dim i As Long
'MyList = Split("dot,com,like", ",")
MyList = Split(" he , He , HE , him , Him , HIM , his , His , HIS , himself , Himself , HIMSELF , she , She , SHE , her , Her , HER , hers , Hers , HERS , herself , Herself , HERSELF ", ",")
For i = 0 To UBound(MyList())
Set r = ActiveDocument.Range
With r.Find
.Text = MyList(i)
.Replacement.Highlight = wdYellow
.Execute Replace:=wdReplaceAll
End With
Next
End Sub
Code:
Sub GenderHighlightRemove()
Dim r As Range
Dim MyList() As String
Dim i As Long
'MyList = Split("dot,com,like", ",")
MyList = Split(" he , He , HE , him , Him , HIM , his , His , HIS , himself , Himself , HIMSELF , she , She , SHE , her , Her , HER , hers , Hers , HERS , herself , Herself , HERSELF ", ",")
For i = 0 To UBound(MyList())
Set r = ActiveDocument.Range
With r.Find
.Text = MyList(i)
.Replacement.Highlight = wdWhite
.Execute Replace:=wdReplaceAll
End With
Next
End Sub
Thanks in advance.
Sharath