Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-05-2018, 04:56 PM
Nanaia Nanaia is offline Highlight words from a list Windows 7 64bit Highlight words from a list Office 2016
Novice
Highlight words from a list
 
Join Date: Dec 2016
Location: Lexington, KY
Posts: 10
Nanaia is on a distinguished road
Default Highlight words from a list


I'm trying to create a macro so that when it's applied it will highlight specific words from a list of words I have. I've got the macro started however I can't seem to figure out how to keep it from highlighting words within words. For example, I want it to highlight the word in, which it will do, but it also highlights it in the word involved and being. Any help, or recommendation for an alternate macro is appreciated. I know I ran across something like this once before but am having difficulty relocating it. This is what I have so far:

Code:
Sub ListChange()
Dim r As Range
Dim MyList() As String
Dim i As Long
MyList = Split("additionally,ah,almost,big,can be,could,could be,generally speaking,he,in,it,it is,low,many,may,might,most,plenty,she,should,some,these,they,this is,we,with", ",")
For i = 0 To UBound(MyList())
   Set r = ActiveDocument.Range
      With r.Find
         .Text = MyList(i)
         .Replacement.Highlight = wdYellow
         .Execute Replace:=wdReplaceAll
         .MatchWildcards = False
         .MatchWholeWord = True
         .MatchAllWordForms = False
      End With
Next
End Sub

Last edited by macropod; 09-05-2018 at 07:11 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find (highlight) two and more words in a list of 75k single words in Word 2010 Usora Word 8 05-29-2018 03:34 AM
Highlight words from a list Macro to highlight a list of words bakerkr Word VBA 4 10-19-2017 02:23 PM
Highlight words from a list Highlight Words from a Word List JSC6 Word VBA 1 09-30-2014 08:22 PM
Highlight words from a list Using macros to highlight worksheet words referenced in external list/doc. Daniel_NYC Word VBA 1 04-21-2014 03:35 PM
Highlight words from a list VBA to highlight words if used too much aolszewski Word VBA 3 11-23-2013 02:07 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:43 AM.


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