#1
|
|||
|
|||
Help with finding multiple keywords in a single document then highlight
Here is what I am trying to do:
I get an email everyday for auctions with some basic information. I would like to search for keywords in it e.g Audio, Video, Electronics etc. What I like to do is have a macro that I can copy paste the email into a Doc and run the macro with keywords. It should highlight those keywords upon running the macro. I looked for the information on google and instuctions were pointing to remove and replace. Sorry, I am currently a beginner with macros. Any help will be appreciated. A US Navy Veteran |
#2
|
|||
|
|||
Pending a Word answer, you can do the same with a good text editor such as Notepad++ and a regular expression search.
|
#3
|
|||
|
|||
This macro should do what you want.
Save it in your Normal template (ALT+F11). You can edit it to find other keywords. Just add these two lines for each word: Selection.Find.Text = "NextKeyword" Selection.Find.Execute Replace:=wdReplaceAll They would go near the end of the macro. (Leave the last 2 lines as they are, they clean up the Find and Replace Dialog Box so it will work normally the next time you attempt to use it.) Copy the text of any email and paste it into a Word doc window. Run the macro named HighlightItems (ALT+F8) This is the macro code: Sub HighlightItems() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Replacement.Highlight = True Selection.Find.Replacement.Text = "^&" Selection.Find.Text = "audio" Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.Text = "video" Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.Text = "electronics" Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find and highlight multiple words in MS Word document | AtaLoss | Word VBA | 37 | 09-22-2021 12:04 PM |
Finding Earned Values for Different Baselines in a single project | pratik6312 | Project | 1 | 08-22-2013 11:18 AM |
Export data from multiple attachments into a single excel document | Woolstar | Outlook | 0 | 12-07-2011 09:49 AM |
Copying Multiple tables from excel into a single word document | dineshtgs | Word Tables | 1 | 04-07-2011 01:27 AM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |