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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Text from One Word Document into Textbox Control of Another

Status
Not open for further replies.

recondaddy

Technical User
Jun 8, 2005
7
US
Hello everyone!

I've created a template in Word 2007 that displays a user form on loading where the user can enter a few pieces of information and hit an OK button, and with the use of bookmarks in the Word Document, the script will populate the form with the data from the user form and format it appropriately.

One of the textboxes on the user form is a multiline textbox control, where the user can enter the body content of the document. If I type the text in the box, manually, everything works as expected.

However, if I paste the text from another Word document into the textbox, I get an error when I hit the OK button.

I have done some experimentation, and my form also works properly if I copy the text from the Word document into a Notepad file, first, then copy it from the Notepad file into the textbox control.

It appears that this is a "carriage return" issue. If I paste the text from the other Word document into the textbox, delete the pasted carriage returns, and manually enter new carriage returns, the form works properly.

Has anyone ever seen this issue and know a way to fix it?

Thanks for any help you can provide.
 
RESOLVED:
Need to replace the vbLF characters that were being pasted in with vbCR.

Added this line of code in before populating the document with my form data:

Textbox1.Value = Replace(Textbox1.Value, vbLF, vbCR)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top