B
Brad
Hello all. I am trying to format a log file from ACL that is inserted into
Word. There is certain code when commented that we do not want to show up in
the Word document. I cannot seem to write a successful loop to do the
following:
1) Search for the phrase "COMMENT - Begin Delete" in the word document
2) Delete that phrase and any subsequent characters until it finds the next
phrase "COMMENT - End Delete" (inwhich that phrase also needs to be deleted)
My idea was to do something similar to below but I need it to be able to
delete the range multiple times if it appears.
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
Thanks for any help you may be able to provide!
-Brad
Word. There is certain code when commented that we do not want to show up in
the Word document. I cannot seem to write a successful loop to do the
following:
1) Search for the phrase "COMMENT - Begin Delete" in the word document
2) Delete that phrase and any subsequent characters until it finds the next
phrase "COMMENT - End Delete" (inwhich that phrase also needs to be deleted)
My idea was to do something similar to below but I need it to be able to
delete the range multiple times if it appears.
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
Thanks for any help you may be able to provide!
-Brad