Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Book Marks VB Add Line Returns?
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 |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Book Marks VB Add Line Returns?
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 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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I remove returns from each line in word? | Page Layout | |||
Book marks | Formatting Long Documents | |||
How do I convert paragraph marks to new line marks? | Page Layout | |||
Revision marks vertical line. Can we make it a double line? | Microsoft Word Help | |||
Line returns? | New Users |