I need a word macro that finds and replaces repeatedly until there is nothing left to replace. I have searched the forums but can't find any examples.
Basically I am trying to write a macro that amongst other things finds and replaces multiple spaces with a single space. What I can't figure out is how to make it loop until there are no more multiple spaces to replace.
i.e
Psuedo code
Selection.Find.ClearFormatting
Selection.Find.Replacement.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
Do until not found
Selection.Find.Execute Replace:=wdReplaceAll
loop
It's the actual code for Do until not found I am seeking.
Or is this not possible?
Basically I am trying to write a macro that amongst other things finds and replaces multiple spaces with a single space. What I can't figure out is how to make it loop until there are no more multiple spaces to replace.
i.e
Psuedo code
Selection.Find.ClearFormatting
Selection.Find.Replacement.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
Do until not found
Selection.Find.Execute Replace:=wdReplaceAll
loop
It's the actual code for Do until not found I am seeking.
Or is this not possible?