Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop macro to the end of the document

Status
Not open for further replies.

ferrisj

IS-IT--Management
Dec 7, 2004
79
US
I have to make a macro that goes 100 spaces in, makes a paragraph mark and goes to the next line and does this for the whole document. I am not not sure how to get it to loop until the end of the document. Can you please look at this code and tell me what to edit.

THanks


Sub AA_Format()

Selection.MoveRight Unit:=wdCharacter, Count:=100
Selection.TypeParagraph
End Sub
 
Hi ferrisj,

You want to add a paragraph mark every 100 characters?

Ctrl+h to bring up the Find/Replace Dialog
Find [blue]?{100,100}[/blue] -- that's question mark, left brace, one hundred, comma, one hundred, right brace
Replace [blue]^&^p[/blue] -- that's caret, ampersand, caret, letter p
Check "Use Wildcards"
Hit Replace All

Record it if you want code.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
do i just replace the 100's with any other number if i wanted to change it,
 
Tony,

Where is all of this cool brace stuff for find and replace documented?
 
I am trying to do it with 2195 spaces and it keeps telling me that the Find what Dialogue box has a Match Pattern which is not valid.
 
Never mind. It's in the help. I thought I had looked before and not found it.
 
In fact, not necessarly the F1 key but the question mark (?) button in the Find/Replace dialog box.
 
Hi ferrisj,

255 is the largest number you can use. But you can look for multiple occurrences of 255 characters, so this should work ..

?{255,255}?{255,255}?{255,255}?{255,255}?{255,255}?{255,255}?{255,255}?{255,255}?{155,155}



Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top