General discussion
-
Topic
-
Word Macro: how do I loop it until end of file EOF
LockedHi, I would like to perform the following macro till the end of the file, and I don’t know the number of times it has to run.
[pre]
=========begin macro=========
PHP Code:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = “^$^p^$”
.Replacement.Text = “”
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=” ”
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub
========end macro===========
[/pre]This is to replace the Returns with a Space in a word file that are in the middle of a sentence.
Even if you know of a better way, I would still like to know how to repeat any macro till the end of file.
I can’t do a Search-and-Replace because [b]^$[/b] is not a valid thing for the Replace With box, which is obvious. I also don’t know how set conditions in VBA.
Thousand thanks!