Combo list

A

Andrew

Trying to create a combo list, mainly with two and three
options. Can't find instructions anywhere ... Stuck with
only one line so far ... Not sure how to create more
options etc. Any help greatly appreciated.
 
J

Jay Freedman

Hi, Andrew,

Can you give us a little more information about what you're trying to do?

First, do you really need a combo box (user can type in something that isn't
in the list) or just a fixed list of choices?

Second, does this need to be in the body of the document, or can it be in a
dialog that pops up when you enter a field or click a button?

For one possible solution, see
http://www.mvps.org/word/FAQs/TblsFldsFms/AutoTextList.htm. If that doesn't
do the job, please reply in the newsgroup.
 
S

Suzanne S. Barnhill

To use the AutoTextList field correctly, you must create a *new* style for
your AutoText entries (it can be a character style) that contains only the
entries you want in the list. Did you look at
http://www.mvps.org/word/FAQs/TblsFldsFms/AutoTextList.htm, which gives
explicit instructions?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jay Freedman

Hi, Andrew,

If you're seeing all the autotext entries in your list, then you missed the
part (step 6 in the procedure I linked to) about creating a new style
specifically for the AutoTextList and applying it to the new entries. You're
getting the entries for the Normal style instead.

To do a dialog box (called a UserForm in MS-speak), see
http://www.mvps.org/word/FAQs/Userforms/CreateAUserForm.htm. After you get
the hang of that, using text box controls, you'll need to know how to set up
a list box:

- From the Controls toolbox, select the List Box control and drag a
rectangle on the userform.
- In the code pane, there are two dropdown lists just below the toolbar. In
the left-hand one, select UserForm. Then in the right-hand one, select
Initialize. This creates two lines in the code:

Private Sub UserForm_Initialize()

End Sub

Between those lines, type in lines like these:

ListBox1.AddItem "Retired"
ListBox1.AddItem "Employee"
ListBox1.AddItem "Self employed"

Each line adds the words in quotes into the list, in the order shown in the
code. (There is no automatic sorting.)

In step 10 of the procedure, change the code to this (assuming that there's
a bookmark named Employment in the document where the text is supposed to be
pasted in):

With ActiveDocument
.Bookmarks("Employment").Range _
.InsertBefore ListBox1.Value
End With

UserForm1.Hide

(Note: a lot of people miss the fact that there's a space between Range and
the underscore, and leaving it out causes an error.)
 

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