View Single Post
 
Old 07-11-2013, 01:49 AM
kilburfi kilburfi is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Jul 2013
Posts: 2
kilburfi is on a distinguished road
Default Loop action in Word until not found

I have recorded a macro in Word which looks for a '?' and replaces that and everything after it (till the end of the line) with just a pargraph control (to move down to the next line). I have many occurences of ? and various text at the end of each line so have to run the macro as many times as the text exists. The text after the ? is not consistent so I can't just do a find and replace. My current code (from the Macro) which I want to loop is:

Selection.Find.ClearFormatting
With Selection.Find
.Text = "?"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1

Selection.TypeParagraph
Reply With Quote