B
Brad
Hello all. I am working on a macro to delete a range of code from a log file
inserted into MS Word based on beginning and ending keywords. We currently
have a template that kicks off 30 other macros and this feature has been
requested of me to add. What I need to do is the following:
Deleting the followng block of text:
COMMENT - Begin Delete (<---key phrase)
Delete this block of text and
and any subsequent lines until you
run into the the key phrase below
COMMENT - End Delete (<--key phrase)
The key phrases "COMMENT - Begin Delete" and "COMMENT - End Delete" need to
be deleted as well.
I thought I had a good start using the code below but I need to figure out
how to loop it correctly.
Thanks for any help you could provide as the deadline for this is by tomorrow!
Selection.Find.ClearFormatting
With Selection.Find
.Text = "COMMENT - Begin Delete"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Extend
Selection.ClearFormatting
With Selection.Find
.Text = "COMMENT - End Delete"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete
Selection.HomeKey Unit:=wdStory
inserted into MS Word based on beginning and ending keywords. We currently
have a template that kicks off 30 other macros and this feature has been
requested of me to add. What I need to do is the following:
Deleting the followng block of text:
COMMENT - Begin Delete (<---key phrase)
Delete this block of text and
and any subsequent lines until you
run into the the key phrase below
COMMENT - End Delete (<--key phrase)
The key phrases "COMMENT - Begin Delete" and "COMMENT - End Delete" need to
be deleted as well.
I thought I had a good start using the code below but I need to figure out
how to loop it correctly.
Thanks for any help you could provide as the deadline for this is by tomorrow!
Selection.Find.ClearFormatting
With Selection.Find
.Text = "COMMENT - Begin Delete"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Extend
Selection.ClearFormatting
With Selection.Find
.Text = "COMMENT - End Delete"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete
Selection.HomeKey Unit:=wdStory