Drop-down Lists and Auto-Population

G

George Gueorguiev

Hello,

I'm working on a Word (2007/2010) document and trying to create a table full
of drop-down lists. I want to be able to select a value from each drop down,
and have this selection show up later in the document. I've been plugging
through VB trying to write this up, but I can't seem to set up a label or
field that I can write a value to. For example, it would look something like
this:
We've got a drop-down list at the top of the document, 3rd page and a
label/text field on, say, page 6. User selects "Option 2" in the drop-down
list. Instantly, the label/text field reads "Option 2".

How can I accomplish this?

Thank you very much for your time & assistance.
 
J

Jay Freedman

I'll assume you're dealing with legacy form fields and not content
controls...

Each dropdown needs an exit macro that transfers the .Result of the dropdown
to the .Result of the corresponding text field. As an extremely simplified
example, if there was only one dropdown and one text field, you could use
this:

Sub ExitDD()
With ActiveDocument.FormFields
.Item("Text1").Result = .Item("Dropdown1").Result
End With
End Sub

Of course, the names in quotes would need to match the bookmark names of the
fields.

If the bookmark name of each dropdown field corresponds to the name of its
text field -- for example, with the same number attached to the end of the
name -- then you could make just one exit macro and assign it to all of the
dropdowns. That macro would have to figure out the name of the dropdown that
was just exited
(http://www.word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm) and compute
the name of the corresponding text field.

By the way, if you are using content controls, they don't have exit macros,
but there is a completely different mechanism for linking them. See
http://gregmaxey.mvps.org/Mapped_Content_Control.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

George Gueorguiev

Thanks for your help Jay, this is exactly the information I was looking for.

I'm using content controls by the way, and got my project working. Many
thanks!
 

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