Results 1 to 14 of 14
  1. #1
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Transferring Information entered in a User Form (English/Word 2003)

    I'm not sure if this a Word issue or a VBA issue, but I have a macro set up that uses a User Form to capture some of the information required on the form. The User Form has three text fields that are multilines and the enter key is set to true. The information is transferred to a protected form (a table) with formfields using the following code:
    activedocument.formfields ("ClientName").result=txtClient
    Sounds pretty simple, but if there is more than one line entered in the User Form, the information is all put on one line with a blank rectangle in between in the cell of the protected form. Another line of code uses a string to capture four separate textboxes in the User Form and print them in the form in one table cell. In the string the vbCr code is used to separate the address from the city, etc, but again no paragraph return, and two rectangles are printed in the cell of the protected Form.

    Has anyone heard of this before? Is it just a glitch on my system? Does anyone know how to fix it? Should I just add a search and replace to my macro to get rid of those rectangles and replace with paragraph marks?

    Any help would be appreciated.

    Thank you so much.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Transferring Information entered in a User For

    <P ID="edit" class=small>(Edited by jscher2000 on 18-Oct-07 22:39. )</P>It appears that the "box" (non-displayed) character is vbCrLf. You can use Replace to change it to vbCr:

    <code>ActiveDocument.FormFields("Text1").Result = Replace(Me.TextBox1.Value, vbCrLf, vbCr)</code>

  3. #3
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Re: Transferring Information entered in a User For

    I tried that, but it is still doing it. Anything else you can recommend?

    Thanks so much.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transferring Information entered in a User For

    I tried the code suggested by JScher2000, and it worked as intended - see below.

    If you can't make it work, you might attach a sample document with a userform.
    Attached Images Attached Images
    • File Type: png x.PNG (5.9 KB, 1 views)

  5. #5
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Re: Transferring Information entered in a User For

    Here you go. I tried using the code for the first two, but kept the original code on the third one.

    Give it a shot and let me know. I would love to get this issue resolved.

    Thanks so much. Here is the code. Unfortunately, it won't let me upload it as it is too big.

    Very long code fragment moved to attachment by HansV
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transferring Information entered in a User For

    Just the code doesn't help.

    You can strip out most of the document, and you can zip it if necessary.

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Transferring Information entered in a User For

    > I tried that, but it is still doing it. Anything else you can recommend?
    Perhaps the users are not inserting a paragraph break but instead pressing some other strange key combination. Can you save a document with the problem and upload it? You can omit the code, I just want to see exactly what characters are in the field.

  8. #8
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Re: Transferring Information entered in a User For

    I zipped the files and hopefully this works now.

    Thanks again so much for your help.
    Attached Files Attached Files

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transferring Information entered in a User For

    You need to post frmFileOpenReport.frx too (zipped)

  10. #10
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Re: Transferring Information entered in a User For

    Here is the finished document and you should see under Client Name, Re and Billing Address the little squares I am referring to. I had to zip it as it is too big otherwise.

    Thanks so much for all the help.
    Attached Files Attached Files

  11. #11
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Re: Transferring Information entered in a User For

    Here it is. Sorry about that.

    Thanks again
    Attached Files Attached Files

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transferring Information entered in a User For

    Ah yes. It is because the form fields are in a table. This is a strange quirk in Word. One solution is to replace vbCrLf with vbVerticalTab instead of vbCr, for example

    ActiveDocument.FormFields("ClientName").Result = Replace(Me.txtClient.Value, vbCrLf, vbVerticalTab)

    Source: How to set the result of a text formfield in a Word 2000 table, using VBA, if the string contains carriage returns

  13. #13
    Star Lounger
    Join Date
    Sep 2007
    Posts
    54
    Thanks
    7
    Thanked 1 Time in 1 Post

    Re: Transferring Information entered in a User For

    IT WORKS IT WORKS IT WORKS.

    Thank you all so much for all your help!!!! I could just kiss all of you right now!

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transferring Information entered in a User For

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •