Removing VbCr characters

shashidharkr
11-17-2004, 01:46 PM
I have a text box, from which I read the text & copy it to MS word document. In the word document, along with new line, VbCr is also copied in the form of squares. These are printed at the beginning of each line. How can this be avoided?

rick_deacha
11-17-2004, 01:50 PM
Search info about Replace()

shashidharkr
11-17-2004, 02:15 PM
I tried using space or vbNullString in place of vbCrLf characters. This will make the text as a single string. But, I want to retain the text in the same form as it was typed in the text box. I need same number of lines as typed in text box.

tinyjack
11-17-2004, 02:22 PM
Instead of replacing vbCrLf just replace vbCr. If it is like Excel, you might have to do this via an intermidiate string variable.

TJ

shashidharkr
11-18-2004, 05:45 AM
Instead of replacing vbCrLf just replace vbCr.
It does not help. Contents of text box comes as a single string. I want the contents to appear in the same way as entered in text box.

shashidharkr
11-18-2004, 10:38 AM
Any thoughts on this ??? :o

rick_deacha
11-18-2004, 10:50 AM
You could check the Split Function
http://www.xtremevbtalk.com/showthread.php?t=197954

shashidharkr
11-18-2004, 12:11 PM
Using split function, I can split the string with vbCrLf delimiter, which creates an array of strings. But, when I copy it to word document, how can it be copied in the same way as it was entered in text box?

Agent707
11-18-2004, 12:18 PM
I have a text box, from which I read the text & copy it to MS word document. In the word document, along with new line, VbCr is also copied in the form of squares. These are printed at the beginning of each line. How can this be avoided?
This problem doesn't make sense. Are you physically copying and pasting the code from your program to Word, or are you using the word object model in your program and doing the copy/paste with code?

Maybe you have your Word in "outline" mode. :eek:
;)

Why don't you post some of your code so we can see how you're doing this. Word should NOT be displaying a box for white space characters... It's just not it's thing.

shashidharkr
11-18-2004, 12:43 PM
No. It is not just physical copy/paste. I am using the word object to create word document.
I have a text form field in the reference document, which is used as template. This text form field in word document is filled with text from the text box in vb6 application.

.....
wField As Word.FormField
.....
wField.Result = txtText1.Text
.....
I have the word document in Print Layout mode. However, it should not matter. And, box is displayed for new line character. :o And it is the thing !!! ;)

Agent707
11-18-2004, 02:23 PM
It appears that when you insert the text, it adds an additional Carriage-Return.

I tested this and it seemed to work

ActiveDocument.FormFields("Text1").Result = Form1.Text1.Text
'If you do an Asc search, you'll see Asc(13) + Asc(10) + Asc(13) all together...
'Replace (vbCrlf & vbCr) with just vbCrLf after you've placed your text in there.
ActiveDocument.FormFields("Text1").Result = _
Replace(ActiveDocument.FormFields("Text1").Result, vbCrLf & vbCr, vbCrLf)

Not the cleanest looking code, but seems to work.

shashidharkr
11-18-2004, 02:36 PM
[QUOTE=Agent707]
ActiveDocument.FormFields("Text1").Result = Form1.Text1.Text
'If you do an Asc search, you'll see Asc(13) + Asc(10) + Asc(13) all together...
'Replace (vbCrlf & vbCr) with just vbCrLf after you've placed your text in there.
ActiveDocument.FormFields("Text1").Result = _
Replace(ActiveDocument.FormFields("Text1").Result, vbCrLf & vbCr, vbCrLf)

That's fentastic!!! :) It works :cool: ;)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum