Macro for drop down lists

F

Fly Fisher

Hi, this may be an elementary question, but I don't have much experience
creating macos.

I have created a form with a combination of text fields, check boxes and
drop downs. To make it easier for the user, I want to create a macro so that
if they choose a location name, it automatically fills in the location
address, and phone numbers that are in different drop downs. But when I try
to record a macro, it won't let me pick from a drop down. Am I missing a
step
here? I think it may be easier to program in Excel, but this is a Word
form. I have read some previous entries on this site and it looks like I may
have to use programming language. If so, how do I do that and what is it?

Thanks in advance for the help.
 
J

Jay Freedman

Fly said:
Hi, this may be an elementary question, but I don't have much
experience creating macos.

I have created a form with a combination of text fields, check boxes
and drop downs. To make it easier for the user, I want to create a
macro so that if they choose a location name, it automatically fills
in the location address, and phone numbers that are in different drop
downs. But when I try to record a macro, it won't let me pick from a
drop down. Am I missing a step
here? I think it may be easier to program in Excel, but this is a
Word form. I have read some previous entries on this site and it
looks like I may have to use programming language. If so, how do I
do that and what is it?

Thanks in advance for the help.

You won't be able to do this with the recorder, but the programming isn't
too difficult. Greg Maxey has a tutorial on this at
http://gregmaxey.mvps.org/Linked_DropDown_Fields.htm.

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

Greg Maxey

Fly Fisher,

You might want to reconsider your technique. It the location address and
phone number is unique to the location picked then you don't need (or want)
the user to have to pick it from another list (they could pick wrong despite
your best efforts). Instead, use a onExit macro in the location dropdown to
automatically fill in the other information at a bookmark.

Say you have a dropdown named DDLoc with the first entry "Atlanta" and the
second "Chicago." Place a bookmark (lets call it "Add") where the address
needs to go.

Then use something like:

Sub DDLocOnExit()
Dim oDD As DropDown
Dim oRng As Word.Range
Set oDD = ActiveDocument.FormFields("DDLoc").DropDown
Set oRng = ActiveDocument.Bookmarks("Add").Range
ActiveDocument.Unprotect
Select Case oDD.Value
Case 1
oRng.Text = "123 Peachtree Street, Atlanta GA 12345"
Case 2
oRng.Text = "456 Central Ave, Chicago IL 12345"
End Select
ActiveDocument.Bookmarks.Add "Add", oRng
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub


Fly said:
Hi, this may be an elementary question, but I don't have much
experience creating macos.

I have created a form with a combination of text fields, check boxes
and drop downs. To make it easier for the user, I want to create a
macro so that if they choose a location name, it automatically fills
in the location address, and phone numbers that are in different drop
downs. But when I try to record a macro, it won't let me pick from a
drop down. Am I missing a step
here? I think it may be easier to program in Excel, but this is a
Word form. I have read some previous entries on this site and it
looks like I may have to use programming language. If so, how do I
do that and what is it?

Thanks in advance for the help.

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 

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