Results 1 to 12 of 12
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Multiple lines in document variables (WinXP/WordXP

    Hi folks, I'm sorry I know I should search for this first but I'm on a deadline and I'd be really grateful if someone would just let me know the answer (or give me a link to a thread that does!) - thank you so much!

    I have a letter with a userform, one of whose fields is an address field, obviously multi-line with returns. This is being transferred to the document (and back, on re-opening the document) via a document variable - but of course document variables translate returns into little boxes that don't make a new line.

    Please could someone remind me how to get returns back into the results?!!

    Many thanks
    Beryl M


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

    Re: Multiple lines in document variables (WinXP/WordXP

    Some information, please.

    How are you storing the address in the document variable?
    How are you transferring the address into the document? Using a DocVariable field, or using TypeText, or ...?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Multiple lines in document variables (WinXP/Wo

    On running template, userform runs, user fills in, template transfers contents to docvariable fields (minus returns!); on opening document later, userform picks up contents of docvariable fields and puts into form again.

    Interestingly, the form reads the address correctly (with returns) when it pulls it back into the form on opening, so it looks like it's just something to do with the display when the text is pasted into the docvariable field?

    Thanks, Hans!
    Beryl M


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

    Re: Multiple lines in document variables (WinXP/Wo

    Try code like this when storing the contents of the text box into the document variable:

    ActiveDocument.Variables("Address").Value = Replace(Me.txtAddress.Value, vbCrLf, vbCr)

    where Address is the name of the document variable and txtAddress is the name of the text box on the userform.
    You'll have to update the DOCVARIABLE field in the document to see the result.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Multiple lines in document variables (WinXP/Wo

    Hi Hans, thanks for this, but it only replaced the two boxes with one! See screendump ...
    Beryl M


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

    Re: Multiple lines in document variables (WinXP/Wo

    I'll need to know exactly what you are doing. It would be easiest if you could post a stripped down and zipped copy of your template.

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Multiple lines in document variables (WinXP/Wo

    As requested.
    Beryl M


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

    Re: Multiple lines in document variables (WinXP/Wo

    It worked differently for you than for me because the DOCVARIABLE field is in a table cell. Excactly why, I don't know either. Try this:

    ActiveDocument.Variables("Address") = Replace(Me.txtAdd, vbCrLf, Chr(7))

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Multiple lines in document variables (WinXP/Wo

    Bingo, Hans! Many thanks!

    Once I remembered to reverse the replace putting the fields back in the userform on opening the doc, it worked perfectly!!

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> !!!
    Beryl M


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

    Re: Multiple lines in document variables (WinXP/Wo

    I hope it doesn't have unexpected side effects: Chr(7) is normally used as the end-of-cell marker.

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Multiple lines in document variables (WinXP/Wo

    Not so far ... !
    Beryl M


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

    Re: Multiple lines in document variables (WinXP/Wo

    Good! <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>

Posting Permissions

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