box symbols appears in the document from docvariable

A

Associates

Hi,

In the userform, i have a textbox that allows user to type in multiple
lines. It's used for the letter's body text. I use DOCVARIABLE to capture the
value of the textbox in the document. However, i saw some box symbols
appearing in the document after dumping all the user data from the userform
into the document.

For example, in the textbox, i typed in as follows
----------------
This is for testing

Thank you
----------------

what i saw in the document was
----------------
This is for testing
[]
[]Thank you
----------------

I use [ and ] characters to describe the box symbol in the document. Not
sure if this is to do with DOCVARIABLE not being able to work with "enter"
carriage key.

I wonder what the box [] represents.

Thank you in advance
 
J

Jay Freedman

Hi,

In the userform, i have a textbox that allows user to type in multiple
lines. It's used for the letter's body text. I use DOCVARIABLE to capture the
value of the textbox in the document. However, i saw some box symbols
appearing in the document after dumping all the user data from the userform
into the document.

For example, in the textbox, i typed in as follows
----------------
This is for testing

Thank you
----------------

what i saw in the document was
----------------
This is for testing
[]
[]Thank you
----------------

I use [ and ] characters to describe the box symbol in the document. Not
sure if this is to do with DOCVARIABLE not being able to work with "enter"
carriage key.

I wonder what the box [] represents.

Thank you in advance

When you press Enter in a userform text box, that places the two characters
Chr(10) and Chr(13) in the text stream; these are the ASCII characters for line
feed and carriage return, respectively (see
http://en.wikipedia.org/wiki/Newline#History). The userform passes these
characters directly into the document variable. In the document, however, Word
uses only Chr(13) as the paragraph mark. The Chr(10) is unnecessary, and it's
what appears as the box character.

To fix this, in the userform code where you assign the text box's content to the
document variable, use the Replace function to strip out any Chr(10) that might
be there, something like this:

ActiveDocument.Variables("test").Value = Replace(TextBox1.Text, Chr(10), "")
 
A

Associates

Thank you, Jay

It works now. I'll keep in mind about those two characters.

Thanks again.

Jay Freedman said:
Hi,

In the userform, i have a textbox that allows user to type in multiple
lines. It's used for the letter's body text. I use DOCVARIABLE to capture the
value of the textbox in the document. However, i saw some box symbols
appearing in the document after dumping all the user data from the userform
into the document.

For example, in the textbox, i typed in as follows
----------------
This is for testing

Thank you
----------------

what i saw in the document was
----------------
This is for testing
[]
[]Thank you
----------------

I use [ and ] characters to describe the box symbol in the document. Not
sure if this is to do with DOCVARIABLE not being able to work with "enter"
carriage key.

I wonder what the box [] represents.

Thank you in advance

When you press Enter in a userform text box, that places the two characters
Chr(10) and Chr(13) in the text stream; these are the ASCII characters for line
feed and carriage return, respectively (see
http://en.wikipedia.org/wiki/Newline#History). The userform passes these
characters directly into the document variable. In the document, however, Word
uses only Chr(13) as the paragraph mark. The Chr(10) is unnecessary, and it's
what appears as the box character.

To fix this, in the userform code where you assign the text box's content to the
document variable, use the Replace function to strip out any Chr(10) that might
be there, something like this:

ActiveDocument.Variables("test").Value = Replace(TextBox1.Text, Chr(10), "")


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 

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