C
Cathy Finnegan
I have a log file containing login information. Each line is a separate login.
What I need to do is delete every line in the document containing a specified string.
I've written a macro (see code below) which doesn't work very well. There has to be a better way to do this!!
Can someone tell me how to do this more efficiently or better??
Any help/or suggestions is greatly appreciated.
TIA,
cathy
~~~~~~~~~ code ~~~~~~~~
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "Login succeeded for user 'me'. Connection: Non-Trusted."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With ' .find
End With ' selection
Do While Selection.Find.Execute
With Selection
.HomeKey Unit:=wdLine
.EndKey Unit:=wdLine, Extend:=wdExtend
.Delete Unit:=wdCharacter, Count:=1
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "Login succeeded for user 'me'. Connection: Non-Trusted."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With ' .find
End With ' selection
Loop 'do while
What I need to do is delete every line in the document containing a specified string.
I've written a macro (see code below) which doesn't work very well. There has to be a better way to do this!!
Can someone tell me how to do this more efficiently or better??
Any help/or suggestions is greatly appreciated.
TIA,
cathy
~~~~~~~~~ code ~~~~~~~~
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "Login succeeded for user 'me'. Connection: Non-Trusted."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With ' .find
End With ' selection
Do While Selection.Find.Execute
With Selection
.HomeKey Unit:=wdLine
.EndKey Unit:=wdLine, Extend:=wdExtend
.Delete Unit:=wdCharacter, Count:=1
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "Login succeeded for user 'me'. Connection: Non-Trusted."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With ' .find
End With ' selection
Loop 'do while