using drop down field in macros

S

schip

I have a from with drop down fields that I would like to be able to use with
a macro. When I try to create the macro, it allows a place for the drop down
but I cannot include the list in the drop down while in the macro. I have
only been able to run the macro and then add the list to the fields then. I
want the list to be included in the macro. Is this possible?
 
R

Russ

Schip,
Word2007?
Is this a listbox in a document with formfields or a listbox in a userform
popup dialog window?
Are you recording a macro while using the menus? It would help us, if you
said what menus choices you are using. Then we would have a better idea of
what kind of dropdown you are talking about.

What is the source for populating your drop down list?
Is it already available or do you need to provide new list data each time?

You may have to use a userform popup dialog to enter a list of choices for
your macro.
 
F

fumei via OfficeKB.com

schip said:
I have a from with drop down fields that I would like to be able to use with
a macro. When I try to create the macro, it allows a place for the drop down
but I cannot include the list in the drop down while in the macro. I have
only been able to run the macro and then add the list to the fields then. I
want the list to be included in the macro. Is this possible?


We definitely need more information. I have no doubt that you can get the
list into a macro.

What kind of a dropdown? How did you make it?
 
S

schip

The form is for other users to complete by choosing from the drop down menu.
This is the beginning:

Patient presents for injection #(drop down with #1-5) of (drop down w/left
knee, right knee, bilateral knees)

Pain: (drop down with Improved Same Worse)

Swelling: "

Activity level: "

I have created the form with the drop downs, but instead of having a "hard
copy" form I wanted the user to be able to use a macro on a clean word
document and get all the info. So I was able to create a simple macro and
add drop down fields in the places indicated above, but I cannot add the
items into the drop down while recording the macro.

I don't know if that explains anything any better, I think I have actually
even confused myself with that explanation!

Thanks
 
F

fumei via OfficeKB.com

Well you certainly did not help all that much.

Just a note/suggestion.

The stuff about the patients, their knees, their pain, is TOTALLY irrelevant.
It means nothing to us. The actual items, the text of what those items are,
is absolutely irrelevant. If an item is "Jupiter", or "Zimbabwe", or "corn",
or "wsgfjhskdgh" makes no difference at all.

PLUS: when you mention youi made a macro...do you notthink it may (it may not.
..but it may) help if you told us what it IS. As in...post some code?

PLUS: it is not helpful at all when you do not answer questions. You were
asked directly "What kind of dropdown? How did you make it"

If you do not bother to answer, then you simply are not going to get much
assistance...no matter how much we would like to.
The form is for other users to complete by choosing from the drop down menu.
This is the beginning:

Patient presents for injection #(drop down with #1-5) of (drop down w/left
knee, right knee, bilateral knees)

Pain: (drop down with Improved Same Worse)

Swelling: "

Activity level: "

I have created the form with the drop downs, but instead of having a "hard
copy" form I wanted the user to be able to use a macro on a clean word
document and get all the info. So I was able to create a simple macro and
add drop down fields in the places indicated above, but I cannot add the
items into the drop down while recording the macro.

I don't know if that explains anything any better, I think I have actually
even confused myself with that explanation!

Thanks
[quoted text clipped - 6 lines]
What kind of a dropdown? How did you make it?
 
D

David Sisson

Sounds like the dropdowns are on your document. If that is the case,
you can unporotect your document, right click on the dropdown, and
select properties. From here you can manually add the dropdown items,
but there is a limit of 25 per dropdown. If you want more, you'll
have to use a dropdown on a userform.
 
S

schip

Sorry. I am very new at this and guess I don't know what terms I should be
using. I understand the actual text is irrelevant, I was hoping to just show
what I was trying to do.

As far codes for the macro go, I am just so elementary that I don't know
what you mean. If I should have copied some of it to show, here it is:
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.TypeText Text:=" of "
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Pain: "
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown

..... but that includes my irrelevant text so I don't know if that is what
you wanted or not.

Lastly, I would like to say I was surprised by your response. My impression
was this was a board for help on any level, didn't realize I needed to be on
a higher level to qualify. Don't need the attitude, I have my own.

fumei via OfficeKB.com said:
Well you certainly did not help all that much.

Just a note/suggestion.

The stuff about the patients, their knees, their pain, is TOTALLY irrelevant.
It means nothing to us. The actual items, the text of what those items are,
is absolutely irrelevant. If an item is "Jupiter", or "Zimbabwe", or "corn",
or "wsgfjhskdgh" makes no difference at all.

PLUS: when you mention youi made a macro...do you notthink it may (it may not.
..but it may) help if you told us what it IS. As in...post some code?

PLUS: it is not helpful at all when you do not answer questions. You were
asked directly "What kind of dropdown? How did you make it"

If you do not bother to answer, then you simply are not going to get much
assistance...no matter how much we would like to.
The form is for other users to complete by choosing from the drop down menu.
This is the beginning:

Patient presents for injection #(drop down with #1-5) of (drop down w/left
knee, right knee, bilateral knees)

Pain: (drop down with Improved Same Worse)

Swelling: "

Activity level: "

I have created the form with the drop downs, but instead of having a "hard
copy" form I wanted the user to be able to use a macro on a clean word
document and get all the info. So I was able to create a simple macro and
add drop down fields in the places indicated above, but I cannot add the
items into the drop down while recording the macro.

I don't know if that explains anything any better, I think I have actually
even confused myself with that explanation!

Thanks
I have a from with drop down fields that I would like to be able to use with
a macro. When I try to create the macro, it allows a place for the drop down
[quoted text clipped - 6 lines]
What kind of a dropdown? How did you make it?
 
D

David Sisson

How about this?
Sub ChooseMe()
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormDropDown

ActiveDocument.FormFields(1).DropDown.ListEntries.Add "This is option
1.1"
ActiveDocument.FormFields(1).DropDown.ListEntries.Add "This is option
1.2"

Selection.TypeText Text:=" of "

Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormDropDown
ActiveDocument.FormFields(2).DropDown.ListEntries.Add "This is option
2.1"
ActiveDocument.FormFields(2).DropDown.ListEntries.Add "This is option
2.2"

Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Pain: "
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormDropDown


End Sub
 

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