Thread: Checking Gender
View Single Post
 
Old 07-02-2014, 03:19 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub GenderHilite()
Dim Rslt
Rslt = InputBox("Choose an option:" & vbCr & "1. Hilight Male" & vbCr & "2. Hilight Female" _
  & vbCr & "3. Un-Hilight Male" & vbCr & "4. Un-Hilight Female")
Select Case Trim(Rslt)
  Case "": Exit Sub
  Case 1: Call HighlightToggle(0, wdTurquoise)
  Case 2: Call HighlightToggle(1, wdPink)
  Case 3: Call HighlightToggle(0, wdNoHighlight)
  Case 4: Call HighlightToggle(1, wdNoHighlight)
End Select
End Sub
 
Sub HighlightToggle(Gender As Long, Hilite As Long)
Dim i As Long, StrGen As String
StrGen = "<[Hh][Ee]> <[Hh][Ii][MmSs]> <[Hh][Ii][Mm][Ss][Ee][Ll][Ff]>|" & _
  "<[Ss][Hh][Ee]> <[Hh][Ee][Rr]> <[Hh][Ee][Rr][Ss]> <[Hh][Ee][Rr][Ss][Ee][Ll][Ff]>"
StrGen = Split(StrGen, "|")(Gender)
Options.DefaultHighlightColorIndex = Hilite
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .Wrap = wdFindContinue
  .MatchWildcards = True
  .Replacement.Highlight = True
  For i = 0 To UBound(Split(StrGen, " "))
    .Text = Split(StrGen, " ")(i)
    .Execute Replace:=wdReplaceAll
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote