# MS Word -  find and automatically underline certain words



## skyport (Dec 30, 2014)

Hope there is an answer for this from someone.  These forums have been great.  I need a way to have a set of key words underlined automatically in a word document. 

HELP!!!!!


----------



## mole999 (Dec 31, 2014)

check out auto correct


----------



## skyport (Jan 2, 2015)

Hi Mole,

thanks for responding.   The auto correct won't do what I need but thanks for trying.  I did get a solution from someone on the Excel side of life and as long as I process the document through excel where I can have the underling automated by a macro, I can always copy it back to word as the final result


----------



## Macropod (Jan 3, 2015)

You can do what you're after in Word, using Find/Replace in a macro. For example:

```
Sub Demo()
Application.ScreenUpdating = False
Dim StrFnd As String, i As Long
StrFnd = "One,Two,Three"
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Replacement.Text = "^&"
  .Replacement.Font.Underline = wdUnderlineSingle
  .Forward = True
  .Wrap = wdFindContinue
  .MatchCase = True
  .MatchWholeWord = True
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  For i = 0 To UBound(Split(StrFnd, ","))
    .Text = Split(StrFnd, ",")(i)
    .Execute Replace:=wdReplaceAll
  Next
End With
Application.ScreenUpdating = True
End Sub
```
This isn't an automatic process, but assigning the macro to a keyboard shortcut can make it simple to use on an as-required basis.


----------

