Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-18-2011, 06:15 PM
macropod's Avatar
macropod macropod is offline Find and highlight multiple words in MS Word document Windows 7 32bit Find and highlight multiple words in MS Word document Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,527
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

Hi AtaLoss,

Try something based on:
Code:
Sub HiLightList()
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "dog,cat,pig,horse,man"
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
Note: Because I've set 'MatchAllWordForms = True', a Find for 'cat' or 'man' will also find & highlight 'cats' & 'men'. Apart from that, the matched words must be whole words. That means you don't need multiple expressions to capture the various forms of a given word.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 05-19-2011, 07:36 AM
AtaLoss AtaLoss is offline Find and highlight multiple words in MS Word document Windows 2K Find and highlight multiple words in MS Word document Office 2003
Novice
Find and highlight multiple words in MS Word document
 
Join Date: May 2011
Posts: 3
AtaLoss is on a distinguished road
Default Thank you!

Thanks a million - it works perfectly and will save me so much time. Thanks thanks thanks!

Quick follow-up question - there is no way to make that macro work automatically in every word doc, is there? I have a couple hundred word docs to do this keyword search in - do I need for each doc to go to macro, insert module, copy and paste the code, or is there any quicker way (other than me copying/pasting all these docs into a single one)?
Reply With Quote
  #3  
Old 01-28-2016, 07:28 PM
phil in orlando phil in orlando is offline Find and highlight multiple words in MS Word document Windows 10 Find and highlight multiple words in MS Word document Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 1
phil in orlando is on a distinguished road
Default

@macropod
Dude, you saved me hours of work by using your macro to find and highlight multiple words in a word document.
Thank you, thank you, thank you!!!
Phil in Orlando
Reply With Quote
  #4  
Old 08-19-2017, 10:55 AM
jaidinesh jaidinesh is offline Find and highlight multiple words in MS Word document Windows 7 32bit Find and highlight multiple words in MS Word document Office 2013
Novice
 
Join Date: Aug 2017
Posts: 3
jaidinesh is on a distinguished road
Default how can we work with this same code for spaced words like "that is"

How can we work with this code for spaced words like "that is"
Reply With Quote
Reply

Tags
find, highlight, multiple keywords

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and highlight multiple words in MS Word document Lost Word Document and cant find it!!! I saved it but it ISNT there!! APAV Word 9 10-09-2017 01:17 PM
Highlight text and find next instance DrDOS Word 0 11-15-2010 04:02 PM
Lock words in a document, but allow for input within the document tlinde Word 1 02-09-2010 09:07 PM
FInd recurring words in Word 2003 NJ007 Word 4 01-25-2010 03:11 PM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:45 PM.


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