Hello, I am trying to create a Macro in WORD 2010 to be able to search documents for multiple keywords at once and highlight them, but some of the keywords are medical abbreviations so I don't want it to highlight when those letters are part of another word. I am new to the use of Macros. In my search to try to find out how to do this, I learned about Visual Basic for Applications (or better said, saw it). I copied the following and it worked but I have two issues:
1. The aforementioned highlighting of instances where letters are part of a WORD and...
2. I need to know how to create this is such a way that it is available on all documents and I can add a button to the Toolbar that will run it on any document I so choose.
Here's what I did in VBA
Code:
Sub TBI1()
Dim range As range
Dim I As Long
Target List = Array(“TBI”, “Brain”, “face”, “facial”, “CT”, “MRI”, “traumatic”, “subdural”, “cranial”, “cranium”, “deficit”, “GCS”, “LOC”, “consciousness”, “head”, “memory”, “concussion”, “executive”)
For I = 0 To UBound(TargetList)
Set range = ActiveDocument.range
With range.Find
.Text = TargetList(I)
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(Forward:=True) = True
range.HighlightColorIndex = wdYellow
Loop
End With
Next
End Sub
Any help would be greatly appreciated. Thanks