Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Okay maybe I went about this the wrong way. I am creating a letter using a
user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Kenny
I thought I showed you how to code this last night. Private Sub CommandButton1_Click() Dim oBMs As Bookmarks Dim oRng As Word.Range Set oBMs = ActiveDocument.Bookmarks Select Case ComboBox1.Text Case "Army" Set oRng = oBMs("Locator").Range oRng.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" oBMs.Add "Locator", oRng Case "Navy" Set oRng = oBMs("Locator").Range oRng.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" oBMs.Add "Locator", oRng Case "Air Force" Set oRng = oBMs("Locator").Range oRng.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" oBMs.Add "Locator", oRng Case "Marines" Set oRng = oBMs("Locator").Range oRng.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" oBMs.Add "Locator", oRng End Select Set oRng = oBMs("CustomersName").Range oRng.Text = Me.TextBox1.Text oBMs.Add "CustomersNamer", oRng Set oRng = oBMs("AccountNumber").Range oRng.Text = Me.TextBox2.Text oBMs.Add "AccountNumber", oRng Set oRng = oBMs("SocialNumber").Range oRng.Text = Me.TextBox3.Text oBMs.Add "SocialNumber", oRng Set oRng = oBMs("CSRName").Range oRng.Text = Me.TextBox4.Text oBMs.Add "CSRName", oRng Set oRng = oBMs("CSRPhone").Range oRng.Text = Me.TextBox5.Text oBMs.Add "CSRPhone", oRng 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 In the places you want the data repeated add a Reference field to the bookmark name. See: http://gregmaxey.mvps.org/Repeating_Data.htm -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
And I just noticed that you didn't bother to reply. A simple "Thank you"
goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Greg I am sorry. I thought it auto replied a thank you when I click this
answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
My ref code is after a page break, is this causing the problem?
"Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Kenny,
Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the
ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
E-mail me your document.
-- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
did you get it?
"Greg Maxey" wrote: E-mail me your document. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Kenny,
No. Send me feedback using the User Feedback link from the website below. I will respond so you have a good address. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: did you get it? "Greg Maxey" wrote: E-mail me your document. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
what is the email address?
"Greg Maxey" wrote: E-mail me your document. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#12
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
Di you get the file?
"Greg Maxey" wrote: Kenny, No. Send me feedback using the User Feedback link from the website below. I will respond so you have a good address. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: did you get it? "Greg Maxey" wrote: E-mail me your document. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 |
#13
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Help VBA CODE Command button Book marks? Please
I did. Fixed file sent back to you.
-- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Di you get the file? "Greg Maxey" wrote: Kenny, No. Send me feedback using the User Feedback link from the website below. I will respond so you have a good address. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: did you get it? "Greg Maxey" wrote: E-mail me your document. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Thanks Greg, Ill bet you have had a bad day. Well I added the stmt. And the ref still does not show the customers name. I have your code entered just right. The ref is after a page break? Can this cause this problem? I dont know what else to do. The bookmarks themselfes populate great? "Greg Maxey" wrote: Kenny, Its been a long hard day and perhaps my remark was a bit abrupt. I apologize. Add this line just before the .Hide statement ActiveDocument.Fields.Update Your REF fields are inserted using CTRL+F9 and before toggling the field code should look like this { REF "Locator" } { REF "CustomersName" } etc. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Greg I am sorry. I thought it auto replied a thank you when I click this answerd my question. I am very new. Thanks for your help. The ref is not working. When I click the command button it exits the user form, all bookmarks populate, but the REF CustomersName does not update and I get an error? "Greg Maxey" wrote: And I just noticed that you didn't bother to reply. A simple "Thank you" goes a long way around here. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Kenny wrote: Okay maybe I went about this the wrong way. I am creating a letter using a user form. Once user form is filled, press command button, fills form. Problem is that I need to place the same book mark in multiple spots in the document. When I place a bookmark with the same name as one I already have in the document it erases the other. 1. How do I fix this using bookmarks? 2. Should I be using some kind of control in the word doc instead of bookmarks to make this application work better? If so please provide code I am very new. Using MS Office 2003, Please Help, Here is my code. Private Sub CommandButton1_Click() Select Case ComboBox1.Text Case "Army" ActiveDocument.Bookmarks("Locator").Range.Text = "HRC - Indianapolis" _ & vbCr & "ATTN:AHRC-ERP" & vbCr & "8899 East 56th Street" _ & vbCr & "Indianapolis, IN 46249-5301" Case "Navy" ActiveDocument.Bookmarks("Locator").Range.Text = "World Wide Locator" _ & vbCr & "Bureau of Naval Personnel" & vbCr & "PERS 312F" _ & vbCr & "5720 Integrity Drive" & vbCr & "Millington, TN 38055-3120" Case "Air Force" ActiveDocument.Bookmarks("Locator").Range.Text = "HQ AFPC/DPDXIDL" _ & vbCr & "550 C. Street West, Suite 50" & vbCr & "Randolph AFB, TX 78150-4752" Case "Marines" ActiveDocument.Bookmarks("Locator").Range.Text = "Headquarters USMC" _ & vbCr & "Personnel Management Support Branch (MMSB-17)" _ & vbCr & "2008 Elliot Road" & vbCr & "Quantico, VA 22134-5030" End Select With ActiveDocument .Bookmarks("CustomersName").Range _ .InsertBefore TextBox1 .Bookmarks("AccountNumber").Range _ .InsertBefore TextBox2 .Bookmarks("SocialNumber").Range _ .InsertBefore TextBox3 .Bookmarks("CSRName").Range _ .InsertBefore TextBox4 .Bookmarks("CSRPhone").Range _ .InsertBefore TextBox5 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 | |||
Multiple Book Marks??? | Microsoft Word Help | |||
Book marks | Formatting Long Documents | |||
add a command button and when i click on the button it will copy | Microsoft Word Help | |||
Command Button | Microsoft Word Help | |||
Command Button | Tables |