Book Marks VB Add Line Returns?

G

Guest

I am using VB and bookmarks to add addresses. I would like to just use one
bookmark and some how code the entire address into one book mark, but how do
I cause a line return instead of using four or five bookmarks??? see code
please! and thanks.

Private Sub CommandButton1_Click()
Select Case ComboBox1.Text
Case "Army"
ActiveDocument.Bookmarks("Name").Range.Text = "HRC - Indianapolis"
ActiveDocument.Bookmarks("Address1").Range.Text = "ATTN:AHRC-ERP"
ActiveDocument.Bookmarks("Address2").Range.Text = "8899 East 56th Street"
ActiveDocument.Bookmarks("Address3").Range.Text = "Indianapolis, IN
46249-5301"
Case "Navy"
ActiveDocument.Bookmarks("Name").Range.Text = "World Wide Locator"
ActiveDocument.Bookmarks("Address1").Range.Text = "Bureau of Naval
Personnel"
ActiveDocument.Bookmarks("Address2").Range.Text = "PERS 312F"
ActiveDocument.Bookmarks("Address3").Range.Text = "5720 Integrity Drive"
ActiveDocument.Bookmarks("Address4").Range.Text = "Millington, TN
38055-3120"
Case "Air Force"
ActiveDocument.Bookmarks("Name").Range.Text = "HQ AFPC/DPDXIDL"
ActiveDocument.Bookmarks("Address1").Range.Text = "550 C. Street West,
Suite 50"
ActiveDocument.Bookmarks("Address2").Range.Text = "Randolph AFB, TX
78150-4752"
Case "Marines"
ActiveDocument.Bookmarks("Name").Range.Text = "Headquarters USMC"
ActiveDocument.Bookmarks("Address1").Range.Text = "Personnel Management
Support Branch (MMSB-17)"
ActiveDocument.Bookmarks("Address2").Range.Text = "2008 Elliot Road"
ActiveDocument.Bookmarks("Address3").Range.Text = "Quantico, VA 22134-5030"
End Select
With ActiveDocument
.Bookmarks("Text1").Range _
.InsertBefore TextBox1
.Bookmarks("Text2").Range _
.InsertBefore TextBox2
End With
UserForm1.Hide
End Sub

Private Sub UserForm_Initialize()
ComboBox1.AddItem "Army"
ComboBox1.AddItem "Navy"
ComboBox1.AddItem "Air Force"
ComboBox1.AddItem "Marines"
ComboBox1.Style = fmStyleDropDownList
ComboBox1.BoundColumn = 0
ComboBox1.ListIndex = 0
End Sub
 
S

Steve Yandl

Kenny,

Use vbCrLf for carriage return/line feed. Try something like:

strL1 = "John Smith"
strL2 = "1234 Main Street"
strL3 = "Seattle, WA 98125"
strAddy = strL1 & vbCrLf & strL2 & vbCrLf & strL3
ActiveDocument.Bookmarks("Address").Range.Text = strAddy

Steve
 
J

Jay Freedman

The built-in constant vbCr represents a paragraph mark. That can be
stuck into the middle of a string. So for the first group in your
example, you could do this:

ActiveDocument.Bookmarks("Name").Range.Text = "HRC - Indianapolis" _
& vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _
& vbCr & "Indianapolis, IN 46249-5301"

--
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

Similar Threads


Top