Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2014, 10:02 AM
navyguy navyguy is offline Help with finding multiple keywords in a single document then highlight Windows 7 64bit Help with finding multiple keywords in a single document then highlight Office 2010 32bit
Novice
Help with finding multiple keywords in a single document then highlight
 
Join Date: Jan 2014
Location: Michigan
Posts: 1
navyguy is on a distinguished road
Question 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
Reply With Quote
  #2  
Old 01-02-2014, 11:58 PM
eNGiNe eNGiNe is offline Help with finding multiple keywords in a single document then highlight Windows 7 32bit Help with finding multiple keywords in a single document then highlight Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

Pending a Word answer, you can do the same with a good text editor such as Notepad++ and a regular expression search.
Reply With Quote
  #3  
Old 01-03-2014, 12:48 PM
NeilSC NeilSC is offline Help with finding multiple keywords in a single document then highlight Windows 7 64bit Help with finding multiple keywords in a single document then highlight Office 2013
Novice
 
Join Date: Dec 2013
Posts: 24
NeilSC is on a distinguished road
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with finding multiple keywords in a single document then highlight 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
Help with finding multiple keywords in a single document then highlight 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:45 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