[vba] search and format finds

L

leaftye

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top