Thread: Checking Gender
View Single Post
 
Old 07-01-2014, 08:20 PM
Sharath_MS_Forums Sharath_MS_Forums is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Jul 2014
Location: India
Posts: 14
Sharath_MS_Forums is on a distinguished road
Default Checking Gender

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

Last edited by macropod; 07-02-2014 at 12:29 AM. Reason: Added code tags & formatting
Reply With Quote