PC Review


Reply
Thread Tools Rate Thread

Book Marks VB Add Line Returns?

 
 
=?Utf-8?B?S2Vubnk=?=
Guest
Posts: n/a
 
      22nd Sep 2007
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

 
Reply With Quote
 
 
 
 
Steve Yandl
Guest
Posts: n/a
 
      22nd Sep 2007
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




"Kenny" <(E-Mail Removed)> wrote in message
news:5B21B7B1-872B-4B01-84FB-(E-Mail Removed)...
>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
>



 
Reply With Quote
 
Jay Freedman
Guest
Posts: n/a
 
      22nd Sep 2007
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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 22 Sep 2007 08:12:01 -0700, Kenny
<(E-Mail Removed)> wrote:

>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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Book Marks??? =?Utf-8?B?S2Vubnk=?= Microsoft Word Document Management 2 22nd Sep 2007 11:04 PM
Importing from Word table with carriage returns/paragraph marks =?Utf-8?B?YXVkcmV5Ym1vcmlu?= Microsoft Access External Data 1 1st Mar 2007 05:44 PM
Reveal paragraph marks/returns =?Utf-8?B?anNlYQ==?= Microsoft Powerpoint 1 16th Jun 2006 12:17 AM
Revision marks vertical line. Can we make it a double line? =?Utf-8?B?dG9yYWp1ZG8=?= Microsoft Word Document Management 3 15th Dec 2005 03:54 AM
BOOK MARKS Danbuff Windows XP Networking 1 6th Oct 2004 11:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:21 AM.