![]() |
#1
|
|||
|
|||
![]()
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 Sharath Last edited by macropod; 07-02-2014 at 12:29 AM. Reason: Added code tags & formatting |
Tags |
gender check |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Turning On Spell Checking Again | SQLUSA | Word | 9 | 08-01-2012 05:41 PM |
Checking n cells above's content | hanvyj | Excel | 4 | 03-22-2012 03:58 AM |
![]() |
mahenn45 | Word | 1 | 03-01-2012 01:05 AM |
![]() |
Deepy | Excel | 1 | 02-14-2011 05:06 PM |
Checking for DOS executions | ajetrumpet | Excel | 0 | 12-06-2009 02:33 PM |