Search and Replace Question

L

L.A. Lawyer

I want to:

1. Go to the top of the ActiveDocument

2. Search for each instance of "double hard returns" (the equivalent of
hitting "Enter" twice) and replace each instance with a page separator (the
same as hitting Ctrl-Enter).

I also want to know how to do this if the text is held in a string variable.
 
M

macropod

Hi L.A. Lawyer,

Try:
Sub Reformat()
Dim StrDblPar As String, StrPgBrk As String
StrDblPar = "^p^p"
StrPgBrk = "^m"
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = StrDblPar
.Replacement.Text = StrPgBrk
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top