Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2013, 02:45 AM
bakerkr bakerkr is offline Macro to highlight a list of words Windows 7 64bit Macro to highlight a list of words Office 2010 32bit
Novice
Macro to highlight a list of words
 
Join Date: May 2013
Posts: 2
bakerkr is on a distinguished road
Default Macro to highlight a list of words

I came across a macro that will highlight a certain word, in the below example I used the word to.



I'd like to use a list of words, which will allow me to add or delete words as necessary. Is this possible? VBA is okay instead of a macro.

Thanks
Kevin
Code:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
With Selection.Find
  .Text = "to"
  .Replacement.Text = "to"
  .Forward = True
  .Wrap = wdFindContinue
  .Format = True
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow

Last edited by macropod; 05-14-2013 at 08:25 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 05-14-2013, 06:15 PM
fumei fumei is offline Macro to highlight a list of words Windows 7 64bit Macro to highlight a list of words Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Quote:
VBA is okay instead of a macro.
They are the same. VBA = macros. macros = VBA

Code:
Sub ListChange()
Dim r As Range
Dim MyList() As String
Dim i As Long
MyList = Split("dot,com,like", ",")
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
The code highlights all instances of the words in the list (dot, com, like).

Note that nothing is selected.
Reply With Quote
  #3  
Old 05-15-2013, 02:48 AM
bakerkr bakerkr is offline Macro to highlight a list of words Windows 7 64bit Macro to highlight a list of words Office 2010 32bit
Novice
Macro to highlight a list of words
 
Join Date: May 2013
Posts: 2
bakerkr is on a distinguished road
Default Thanks

Thanks for the help,worked great!
Reply With Quote
  #4  
Old 10-19-2017, 08:46 AM
vijayvijay vijayvijay is offline Macro to highlight a list of words Windows 8 Macro to highlight a list of words Office 2010 32bit
Novice
 
Join Date: Oct 2017
Posts: 1
vijayvijay is on a distinguished road
Default

I was looking for something like this. Can the checking of the words can be done from a database excel. I have excel sheet having hundred words and if these words are there in the word file it must be highlighted.
Reply With Quote
  #5  
Old 10-19-2017, 02:23 PM
macropod's Avatar
macropod macropod is offline Macro to highlight a list of words Windows 7 64bit Macro to highlight a list of words Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by vijayvijay View Post
I was looking for something like this. Can the checking of the words can be done from a database excel. I have excel sheet having hundred words and if these words are there in the word file it must be highlighted.
Kindly don't resurrect old threads.

The use of an Excel workbook as a Find/Replace data source has been discussed numerous times. For example: https://www.msofficeforums.com/word-...html#post34254
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to highlight a list of words Find and highlight multiple words in MS Word document AtaLoss Word VBA 37 09-22-2021 12:04 PM
Macro to highlight a list of words How to make it highlight blocks of text (words) without highlighting extra space @end seortm Word 3 03-30-2015 08:12 AM
Macro to highlight a list of words Highlight and then replace multiple words redhin Word VBA 5 03-05-2013 05:42 AM
Macro to highlight a list of words Find and highlight all words ending in -ly RBLampert Word VBA 13 10-23-2012 04:45 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 11:58 AM.


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