L
leaftye
I'm trying to create a procedure that searches for certain words and
then formats those words. Two problems:
1. If I have a word(s) highlighted when I start the macro, it formats
the selection...even though it hasn't found anything yet.
2. It finds the first word, but not the rest.
Please help me figure out what I'm doing wrong. Here's my code:
Code:
--------------------
With Selection
With .Find
.ClearFormatting
.Text = "access"
.MatchCase = False
.MatchWholeWord = True
.Execute
.ClearFormatting
End With
.FormattedText.Case = wdTitleWord
.Font.Underline = wdUnderlineSingle
End With
With Selection
With .Find
.ClearFormatting
.Text = "assignment"
.MatchCase = False
.MatchWholeWord = True
.Execute
.ClearFormatting
End With
.FormattedText.Case = wdTitleWord
.Font.Underline = wdUnderlineSingle
End With
then formats those words. Two problems:
1. If I have a word(s) highlighted when I start the macro, it formats
the selection...even though it hasn't found anything yet.
2. It finds the first word, but not the rest.
Please help me figure out what I'm doing wrong. Here's my code:
Code:
--------------------
With Selection
With .Find
.ClearFormatting
.Text = "access"
.MatchCase = False
.MatchWholeWord = True
.Execute
.ClearFormatting
End With
.FormattedText.Case = wdTitleWord
.Font.Underline = wdUnderlineSingle
End With
With Selection
With .Find
.ClearFormatting
.Text = "assignment"
.MatchCase = False
.MatchWholeWord = True
.Execute
.ClearFormatting
End With
.FormattedText.Case = wdTitleWord
.Font.Underline = wdUnderlineSingle
End With