Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="^m", MatchWildcards:=False,
Wrap:=wdFindStop, Forward:=True) = True
Selection.Range.Delete
Selection.InsertBreak Type:=wdSectionBreakNextPage
Loop
End With
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Grace said:
How would i write a loop to replace a page break with a next page
section
break? The next page section break is not one of the items that you
can
replace with, a section break is only listed as one of the things you
can
find.
:
You don't really need a loop for this; instead, you can use a
Find/Replace
to handle this.
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "(\]\[)(*)(^13)"
.MatchWildcards = True
With .Replacement
.ClearFormatting
.Text = "\1^l\2\3"
.Font.Italic = True
End With
.Execute Replace:=wdReplaceAll
End With
End With
^l (the el letter) is the manual line break. I've put it after the
"][".
HTH,
Dave
message
I am formatting some text with a macro. The macro searches for a
marker
value "][", inserts a manual line break, selects to the end of the
paragraph,
italicizes the selection.
I want to repeat this macro through the entire document. I'm just
not
sure
how to go about forming the loop that does this.
Here is the macro code that performs the operation one time.:
Sub AddTTPCommentBreak()
'
' AddTTPCommentBreak Macro
' Macro recorded 9/19/2006
'
Selection.Find.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
Selection.Find.Execute
Selection.TypeText Text:=Chr(11)
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Italic = wdToggle
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub