I need a dropdown list in Word 2013 to select an Office that will then create an Address in the document

Hello!  I need a dropdown list in Word 2013 to select an Office that will then create an Address in the document.
For instance, we have 5 offices and once the user selects the office via a dropdown box that would then create an address in the actual work document.  

I have no problem using static assignments hard coded in VBA.  (If users selects "Seattle" then we can have references in code that tell Word that the address 123 Main Street, Seattle, WA, 12345.)

I also have no issue if the solution is to launch a popup as soon as the template is opened up that asks "What office".

I don't want the dropdown box (or any controls) to print though.

Help help would be appreciated.  Thanks.
JasonJewettAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
You should use a UserForm.

Add it to the template and add a Combobox and a Command Button, with this code:
Option Explicit


Private Sub ComboBox1_Change()
    Dim rng As Range
    
    Set rng = ActiveDocument.Bookmarks("OfficeAddress").Range
    rng.Text = ComboBox1.List(ComboBox1.ListIndex, 1)
    ActiveDocument.Bookmarks.Add "OfficeAddress", rng 're-add bookmark
    DoEvents 'give up time so that the document gets updated immediately
End Sub


Private Sub CommandButton1_Click()
    Me.Hide
End Sub

Private Sub UserForm_Initialize()
    Dim Offices(2, 1) As String
    
    Offices(0, 0) = "Aldershot"
    Offices(0, 1) = "33 Wellington Street, Aldershot, Hampshire, GU11 1DX"
    Offices(1, 0) = "Guildford"
    Offices(1, 1) = "42 North St, Guildford, Surrey, GU1 4TE"
    Offices(2, 0) = "Woking"
    Offices(2, 1) = "12 Wolsey Walk, Woking, Surrey, GU21 6XU"
    
    ComboBox1.ColumnCount = 2
    ComboBox1.ColumnWidths = "1cm,0"
    ComboBox1.List = Offices
End Sub

Open in new window

Add the bookmark to the template where the address is to appear and put this code in its ThisDocument code module.
Option Explicit

Private Sub Document_New()
    UserForm1.Show vbModeless
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JasonJewettAuthor Commented:
Thanks.  I went a slightly different way, but this helped.  I appreciate it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.