View Single Post
  #1   Report Post  
leaftye
 
Posts: n/a
Default [vba] search and format finds


I figured it out. Here's what my final code looks like:

Code:
--------------------

Sub UnderlineWords()
' Underline all the words in this array

Dim WordsToUnderline(10) As String
WordsToUnderline(0) = "access"
WordsToUnderline(1) = "assignment"

For i = 0 To UBound(WordsToUnderline)
With Selection.Find
.ClearFormatting
With .Replacement
.ClearFormatting
.Font.Underline = wdUnderlineSingle
.Text = WordsToUnderline(i)
End With
.Text = WordsToUnderline(i)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Execute Replace:=wdReplaceAll
End With
Next


End Sub
--------------------


--
leaftye