Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Search Search
Search for:
Tech Support Guy > > >

Word Macro: how do I loop til end of file EOF


(!)

TheSteelGeneral's Avatar
TheSteelGeneral TheSteelGeneral is offline
Computer Specs
Member with 119 posts.
THREAD STARTER
 
Join Date: Apr 2009
08-May-2012, 08:10 AM #1
Word Macro: how do I loop til end of file EOF
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:
    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:=wdCharacterCount:=1
    Selection
.EndKey Unit:=wdLine
    Selection
.TypeText Text:=" "
    
Selection.Delete Unit:=wdCharacterCount:=1
    Selection
.MoveRight Unit:=wdCharacterCount:=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 I get. I also don't know how set conditions in VBA. Thousand thanks!

Last edited by TheSteelGeneral; 08-May-2012 at 08:15 AM..
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


Tags
eof, loop, macro, search and replace

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑