Thanks--
Follow-up question: why "declare" the rng variable rather than just always use Selection.Range? (1) It seems like extra code and (2) it actually seems to break the script.
For example, if I do this,
Code:
With Selection.Range.Find ' Get rid of any stricken-through text
.ClearFormatting 'Is this needed?
.Replacement.ClearFormatting 'Is this needed?
.Text = "*"
.MatchWildcards = True
.Font.StrikeThrough = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
With Selection.Range.Find ' Get rid of any underlining
.Font.Underline = wdUnderlineSingle
.Replacement.Font.Underline = wdUnderlineNone
.MatchWildcards = False
.Text = ""
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
It works as expected, but if I do this:
Code:
Dim rng As Range
Set rng = Selection.Range
With rng.Find ' Get rid of any stricken-through text
.ClearFormatting 'Is this needed?
.Replacement.ClearFormatting 'Is this needed?
.Text = "*"
.MatchWildcards = True
.Font.StrikeThrough = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
With rng.Find ' Get rid of any underlining
.Font.Underline = wdUnderlineSingle
.Replacement.Font.Underline = wdUnderlineNone
.MatchWildcards = False
.Text = ""
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
It doesn't get rid of the underlining.