I have a text file from a legacy system that I am trying to clean up. I have opened the file in word and created a macro to make changes to some of the text, this works without any problems . I then created a macro to find the specific text I was searching for, and a second to delete 2 lines. I then combined them into a single macro. Here is the code.
This works correctly for the first 2 pages, however on the third it no longer is deleteing the lines.
________________Example of p[age 3 before running macro_________________
Total number of claims under audit 3
Number of claims first filed during interim period 3
Non-expired prior claims under audit 0
___________________________________
In the above example I would like to remove the Total number of claims line and the blank line below it.
____________example of third page after running macro_____________
3
Number of claims first filed during interim period 3
Non-expired prior claims under audit 0
_________________
From this point forward to the end of the file it only removes the text I searched for and not the lines.
All help is appreciated, thank you in advance.
Alan
Senility at its finest
Code:
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total number of claims under audit"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End With
Selection.Find.Execute Replace:=wdReplaceAll
________________Example of p[age 3 before running macro_________________
Total number of claims under audit 3
Number of claims first filed during interim period 3
Non-expired prior claims under audit 0
___________________________________
In the above example I would like to remove the Total number of claims line and the blank line below it.
____________example of third page after running macro_____________
3
Number of claims first filed during interim period 3
Non-expired prior claims under audit 0
_________________
From this point forward to the end of the file it only removes the text I searched for and not the lines.
All help is appreciated, thank you in advance.
Alan
Senility at its finest