Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
stacy05 stacy05 is offline
external usenet poster
 
Posts: 1
Default keyword Search Macro?!?

I would like to create a macro or some other kind of function that
automatically highlight keywords when I open a document. Is that a capability
within Word, or is there an outside resource anyone knows of that can
accomplish this?

Thanks!
Stacy

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default keyword Search Macro?!?

The following macros will highlight (and remove the highlight) from a list
of words set in quotes and separated by commas in the line vFindText =


Sub HighlightList()
Dim rDcm As Range
Dim vFindText As Variant
Dim i As Long
Set rDcm = ActiveDocument.Range
'*************************************************
vFindText = Array("Lorem", "dolor", "amet")
'*************************************************
'Selection.HomeKey Unit:=wdStory
With rDcm.Find
.Forward = True
.Wrap = wdFindStop
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True

For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "^&"
.Replacement.Highlight = True
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub RemoveHighlight()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = ""
.Highlight = True
.Replacement.Text = "^&"
.Replacement.Highlight = False
.Execute replace:=wdReplaceAll
End With
End Sub

http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


stacy05 wrote:
I would like to create a macro or some other kind of function that
automatically highlight keywords when I open a document. Is that a
capability within Word, or is there an outside resource anyone knows
of that can accomplish this?

Thanks!
Stacy



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEARCH ON CATEGORY OR KEYWORD IN DOCUMENT PROPERTIES carricka Microsoft Word Help 13 August 5th 09 06:42 AM
Macro for search and replace not working Brad in Tampa Microsoft Word Help 2 August 21st 07 06:01 AM
Search-and-replace macro never works Liam Gibbs Microsoft Word Help 3 May 8th 07 12:38 AM
search and replace macro genius? BobW Microsoft Word Help 1 March 3rd 06 04:40 PM
can I keyword search in Word? Chris Russon New Users 1 December 9th 04 03:50 PM


All times are GMT +1. The time now is 04:43 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"