Macro to fill in the rest of a drop-down

S

sg

I have set up a drop-down box in my form with about 7 choices on it.
However, some of the choices are too long to fit. So, I used the following
macro to fill in the drop-down:

Sub OnExitReinsured_Contracts()
Select Case ActiveDocument.FormFields("Reinsured_Contracts").Result
Case "Membership service agreements"
ActiveDocument.FormFields("Reinsured_Contracts").Result =
"Membership service agreements pursuant to which the Reinsured retains
financial responsibility for eligible health care services provided to"
Case "The indemnity policies"
ActiveDocument.FormFields("Reinsured_Contracts").Result = "The
indemnity policies written by the Reinsured to cover its"

I now have two problems:

1. When I choose the first option listed in the macro "Membership service
agreements" from the drop-down box, it fills in the entire text for me.
However, the text is running off the page and I can't get it to show up. If
I add a new line in the macro window, all the text on the new line turns red.

2. If I choose the 2nd option listed in the macro, nothing happens. The
text on the drop down is not replaced.

I think my problem is that I am trying to populate the same drop-down box
that I am choosing from, but I don't know what else to do.

I am fairly new at this and appreciate any help anyone can offer.
 
D

Doug Robbins - Word MVP on news.microsoft.com

You can use code such as the following to populate a TextInput FormFeld with
an autotext entry, the name of which is selected from a list in a DropDown
FormField.

With ActiveDocument
.FormFields("Text1").result =
..AttachedTemplate.AutoTextEntries(.FormFields("DropDown1").Result).Value
End With


If you had the DropDown and the TextInput formfields suitably located, the
first part of the required text could come from the DropDown and the balance
of it could be provided by the autotext.

It is probably better however to use a UserForm with a two column combobox
with the shortened version in the first column and the complete text in the
second column and then set the .BoundColumn attribute of the combobox to get
the information from the second column for the selected item.

Fellow MVP Greg Maxey has accumulated information on UserForms on the
following pages of his website :

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

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



--
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

sg

Thank you for your quick reply.

I got it to work using the original drop-down and populating the remaining
text into a text box right next to the drop-down. This part works great.

However, (there is always something else...) there are some items on the
drop-down list that are only one word and I don't have anyway to split it
apart so there is one item to choose from the drop-down while the rest fills
in the text box.

Is there a way to delete the text box if it is not filled in?

Again, thank you in advance to anyone who can help!
 
D

Doug Robbins - Word MVP on news.microsoft.com

I think that the best you could do with that method is to create autotext
entries for each of the one word items that contain just a single space.

--
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
 

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