Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2007

Tip: Looking for answers? Try searching our database.

Replacement.Text fails to render vbCrLf

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sandal - 02 Oct 2007 02:40 GMT
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
Greg Maxey - 02 Oct 2007 02:50 GMT
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

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> When I use a statement like
>
[quoted text clipped - 11 lines]
> Some Text
> More text on a new line
sandal - 02 Oct 2007 02:57 GMT
I tried that and vbLf and Chr(13) you name it...
Tony Jollans - 02 Oct 2007 09:05 GMT
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?

Signature

Enjoy,
Tony

>I tried that and vbLf and Chr(13) you name it...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.