Multiple Choice ield on Template

S

Slim Slender

I was given 4 separate letter templates. The only difference is the address.
I would like to combine them into a single template and be able to select the
address needed each time. They are used one at a time which makes me think
that merging is not appropriate. I was thinking some kind of drop down list
to select one of four addressees and a macro that inserted the rest of the
address
 
D

Doug Robbins - Word MVP

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

and the following pages of fellow MVP Greg Maxey's website :

http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

http://gregmaxey.mvps.org/Populate_UserForm_ListBox.htm
If that information is of use to you, please do consider contributing to the
maintenance of that website to ensure its continued availability.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
S

Slim Slender

Thank you so much for the web site references. I studied those and did the
lessons. I found some code that was perfect for my project with only a few
tweeks. I have a form that opens with a Template and displays a list of
states drawn from a table in another file. In the second column of each row
of the source table is one of four cities. All I need now is a way of having
another combo box display what is in column two when something from column
one is selected in ComboBox1. The reason I want a second combobox is that I
would also like Combobox2 populated from the second column of the table on
initialization so that if someone knows the city they can bypass the state
list, open combobox2 and select the city. Once the city is determined by
either method, a particular address is displayed in a label.

Private Sub UserForm_Initialize()
Dim myArray() As Variant
Dim sourcedoc As Document
Dim i As Integer
Dim j As Integer
Dim myitem As Range
Dim m As Long
Dim n As Long
Application.ScreenUpdating = False
'Modify the following line to point to your list member file and open the
document

Set sourcedoc = Documents.Open(FileName:="C:\Documents and
Settings\John\sourceWord.doc")
'Get the number of list members (i.e., table rows -1 if there is a hearder row
i = sourcedoc.Tables(1).Rows.Count - 1
'Get the number of columns in the table
j = sourcedoc.Tables(1).Columns.Count

'Set the number of columns in the list box
'ComboBox1.ColumnCount = j

'Load list members into an array
ReDim myArray(i, j)
For n = 0 To j - 1
For m = 0 To i - 1
Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
myitem.End = myitem.End - 1
myArray(m, n) = myitem.Text
Next m
Next n

'Populate the ComboBox using the array
ComboBox1.List() = myArray

'Cloze th source file
sourcedoc.Close savechanges:=wdDoNotSaveChanges

End Sub

Is the next step a proceduce
Private Sub ComboBox1_AfterUpdate()
 
D

Doug Robbins - Word MVP

If you add

ComboBox2.List() = myArray

to

'Populate the ComboBox using the array
ComboBox1.List() = myArray

and set the width of Column 1 in Combobox2 to 0pt, the states will be
hidden.

To access the city, used Combobox(2).Column(1) 'the column numbers start at
0

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
S

Slim Slender

I would like to pay you to help me with this project
I have an Excel workbook with a table that has state names in Col A and a
corresponding city in Col D. There are only four different cities.
I have a Word template that already has a form in it and listbox1 populated
by the states from the Excel file. I already have listbox2 that displays the
corresponding city when listbox1 is changed.

What I need is to store in the code a multiline address for each of the four
cities and to have that address retrieved and displayed on the form first,
and then placed on the template when a command button is clicked. I will need
specific instructions on how to set up the bookmark or field on the template.
 

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

Top