Replacement.Text fails to render vbCrLf

S

sandal

When I use a statement like

With .Selection.Find
.Replacement.Text = "Some Text" & vbCrLf & "More text on a new line"

I get a mess like

Some Text [][]More text on a new line

Those [] are standing in for little square characters.

It should be simple but how do I get

Some Text
More text on a new line
 
G

Greg Maxey

Try vbCr

e.g.,

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "Test"
.Replacement.Text = "Test" & vbCr & "More text on following line"
.Execute Replace:=wdReplaceAll
End With

End Sub
 
T

Tony Jollans

You should use "^p" to get a paragraph in the body of a word document.

If you are getting little square characters something is odd. Where is the
Selection?
 

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