Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Mar 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Typing an address in a template (Word 2007)

    Hello

    I have a userform in a template that has optionbuttons for entering one of two addresses. How do I code the button so that the text will show up as 3 or 4 lines like the sample below? I want a hard return after each line and what I am getting is just one line with all of the text wrapping. Thanks for any help.


    name
    street
    apt. (if any)
    city, state, zip

  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: Typing an address in a template (Word 2007)

    You want the text to have line breaks in the document or in the user form? It might help to attach the relevant aspects of the project to this thread.

  3. #3
    Lounger
    Join Date
    Mar 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Typing an address in a template (Word 2007)

    I would like the line breaks for the address in the userform.

    This is what I tried to do for the first company option button:

    Private Sub optcompany1_Click()
    If frmsvc.optcompany1.Value = True Then
    ActiveDocument.Bookmarks("address").Range.Text = "Company 1"
    Selection.TypeParagraph
    Selection.TypeText Text:="Department"
    Selection.TypeParagraph
    Selection.TypeText Text:="Street Address"
    Selection.TypeParagraph
    Selection.TypeText Text:="City, State zip"
    End If
    End Sub

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

    Re: Typing an address in a template (Word 2007)

    Does this do what you want?

    ActiveDocument.Bookmarks("address").Range.Text = "Company 1" & vbCr & _
    "Department" & vbCr & "Street Address" & vbCr & "City, State zip"

  5. #5
    Lounger
    Join Date
    Mar 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Typing an address in a template (Word 2007)

    That works perfectly! Thank you.
    What does the vbCr stand for?

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

    Re: Typing an address in a template (Word 2007)

    vbCr is the symbolic constant for ASCII character 13, the carriage return. Word uses this character as end-of-paragraph marker.

Posting Permissions

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