Replace function with format characters

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I have a string variable that can include two vbCr characters together, which
need to be replaced by just one. But the Replace function doesn't seem to
work for either Chr(13) or vbCr. I've done short tests, and I can't get the
function to recognize that character. Suggestions?

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200902/1
 
D

Doug Robbins - Word MVP

Use Replace("some string", vbCr & vbCr, vbCr)

To demonstrate that it works

Dim mystr As String
mystr = "Line 1" & vbCr & vbCr & "Line 2"
Selection.Text = mystr & vbCr & Replace(mystr, vbCr & vbCr, vbCr)


--
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
 

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