Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2015, 04:51 AM
dende012 dende012 is offline Help on Genderhighlight code Windows 7 64bit Help on Genderhighlight code Office 2007
Novice
Help on Genderhighlight code
 
Join Date: Aug 2015
Location: Phil
Posts: 1
dende012 is on a distinguished road
Smile Help on Genderhighlight code

Sub HiLightGender()
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "boy,man,male,gentleman,his,he,guy,girl,woman,fema le,lady,her,she,gal"
For i = 0 To UBound(Split(StrFnd, ","))
Set Rng = ActiveDocument.Range
With Rng.Find
.ClearFormatting
.Text = Split(StrFnd, ",")(i)
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
.Execute Replace:=wdReplaceAll
End With
Next
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
Sub HighlightAllNumbers()
Dim r As Range
Dim MyList() As String
Dim i As Long
'MyList = Split("dot,com,like", ",")
MyList = Split("1,2,3,4,5,6,7,8,9,0", ",")


For i = 0 To UBound(MyList())
Set r = ActiveDocument.Range
With r.Find
.Text = MyList(i)
.Replacement.Highlight = wdPink
.Execute Replace:=wdReplaceAll
End With
Next

End Sub



__________________________________________________ ___

HOW CAN PUT HIGHLIGHT COLOR WHEN USING THIS...

AND ALSO HELP ON HOW TO SEPARATE MALE FROM FEMALE BY COLOR WHEN USING THIS CODE... TNX
Reply With Quote
  #2  
Old 08-05-2015, 06:54 PM
macropod's Avatar
macropod macropod is offline Help on Genderhighlight code Windows 7 64bit Help on Genderhighlight code Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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 HiLightGender()
Application.ScreenUpdating = False
Dim StrFnd As String, i As Long
With ActiveDocument.Range.Find
  .ClearFormatting
  With .Replacement
    .ClearFormatting
    .Text = "^&"
    .Highlight = True
  End With
  .Forward = True
  .Wrap = wdFindContinue
  .Format = True
  .MatchCase = False
  .MatchWholeWord = True
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = True
  Options.DefaultHighlightColorIndex = wdTurquoise
  StrFnd = "boy,man,male,gentleman,his,he,guy"
  For i = 0 To UBound(Split(StrFnd, ","))
    .Text = Split(StrFnd, ",")(i)
    .Execute Replace:=wdReplaceAll
  Next
  Options.DefaultHighlightColorIndex = wdPink
  StrFnd = "girl,woman,female,lady,her,she,gal"
  For i = 0 To UBound(Split(StrFnd, ","))
    .Text = Split(StrFnd, ",")(i)
    .Execute Replace:=wdReplaceAll
  Next
End With
Application.ScreenUpdating = True
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on Genderhighlight code QR-code qrcode Word 3 05-26-2015 06:38 AM
Help on Genderhighlight code code to run once only gerrymac Word VBA 6 07-26-2014 12:19 AM
Help on Genderhighlight code Need Help with Below Code rsrasc Word VBA 6 04-01-2014 03:42 PM
Help on Genderhighlight code Where does my code go? rbaldwin Word VBA 3 03-14-2012 02:31 PM
Help on Genderhighlight code vbc code rajpeter Excel Programming 2 09-13-2011 02:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft