Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Carriage Return/Line Feed control codes in Excel

Status
Not open for further replies.

SteveShanks

Programmer
Nov 28, 2001
112
0
0
GB
Hi Everyone

How can I stop Excel replacing a CR/LF in a text string with a 'square' character code when I programtically insert text into a cell in EXCEL?

I'm using VB.NET with Excel 2003

Many Thanks
Steve
 
The problem is that the string is coming from an Access 2003 database text field that was populated from a VB.NET textbox control so I don't have any control over the control codes for new lines.

If I build a string manually in VB using vbCrLf etc it appears without the control codes in Excel....it's just the strings originating from multiline VB text boxes that cause the problems.

Thanks
Steve
 
Are you able to do a replace on the string before you assign it to a cell?
myString = myString.Replace(vbCrLf, vbLf)
or
myString = myString.Replace(Chr(13), "")
 
Thanks udo321....spot on!

I used
excel.cells(1,1) = mystring.Replace(ControlChars.CrLf, ControlChars.Lf)

Thanks again
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top