J
Julie
Hi All! Is there a way that I can have a macro look for
a certain word in a report, but only when it is at the
start of a line and not in the middle of a name. For
example:
I need to delete the word "MED" out of a report. It is
on multiple lines, and the number of lines varies per
report. The word "MED" can also be found in certain
words like MEDical, interMEDiate, or arMED. How do I get
the macro to only go to the start of the line
(paragraph), grab the information I need to delete, and
then move to the start of the next line (not grabing
other words)? I have posted what I have below. Thanks
in advance and have a great weekend.
Julie
Selection.Find.ClearFormatting
With Selection.Find
.Text = "MED"
.Replacement.Text = _
"
"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.MoveRight Unit:=wdCharacter,
Count:=18, Extend:=wdExtend
Selection.TypeBackspace
Else
Exit Do
End If
Loop
a certain word in a report, but only when it is at the
start of a line and not in the middle of a name. For
example:
I need to delete the word "MED" out of a report. It is
on multiple lines, and the number of lines varies per
report. The word "MED" can also be found in certain
words like MEDical, interMEDiate, or arMED. How do I get
the macro to only go to the start of the line
(paragraph), grab the information I need to delete, and
then move to the start of the next line (not grabing
other words)? I have posted what I have below. Thanks
in advance and have a great weekend.
Julie
Selection.Find.ClearFormatting
With Selection.Find
.Text = "MED"
.Replacement.Text = _
"
"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.MoveRight Unit:=wdCharacter,
Count:=18, Extend:=wdExtend
Selection.TypeBackspace
Else
Exit Do
End If
Loop