Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion


Word Macro: how do I loop it until end of file EOF

By TheSteelGeneral ·
Hi, 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.

=========begin macro=========
PHP Code:
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.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===========

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 ^$ 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!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Repost as 'Q&A'

by CharlieSpencer In reply to Word Macro: how do I loop ...

Try reposting this in the 'Q&A' forum. The 'Discussion' forum is for matters of general discussion, not specific problems in search of a solution. The 'Water Cooler' is for non-technical discussions. You can submit a question to 'Q&A' here:;content

There are TR members who specifically seek out problems in need of a solution. Although there is some overlap between the forums, you'll find more of those members in 'Q&A' than in 'Discussions' or 'Water Cooler'.

Be sure to use the voting buttons to provide your feedback. Voting a '+' does not necessarily mean that a given response contained the complete solution to your problem, but that it served to guide you toward it. This is intended to serve as an aid to those who may in the future have a problem similar to yours. If they have a ready source of reference available, perhaps won't need to repeat questions previously asked and answered. If a post did contain the solution to your problem, you can also close the question by marking the helpful post as "The Answer".

Related Discussions

Related Forums