Drop Down Form Field

G

Guest

I have a Drop Down Form Field inside a table cell. The width of the cell is
smaller than the length of the entries in the drop down list. When one
selection is chosen from the drop down list, only the first few letters
appear. Is there a way to wrap the text of drop down lists so that it fits
inside the cell?
Under Table Properties, i made sure the 'Wrap Text' option is cliked, but it
doesn't seem to work with Drop Down list entries.
Many thanks
Tendresse
I'm using Word 2003
 
G

Graham Mayor

The short answer to your question is that it cannot be done. A more elegant
method would be to use userforms to gather your data and insert it, but with
a little lateral thinking it is possible to cobble something together to do
what you want.

The following macro (run on exit from your dropdown field) assumes that your
dropdown form field bookmark is Dropdown1 and immediately after that field
in the same table cell is a text form field Text1 which has its fillin
enabled property unchecked.

The macro takes the selection from the dropdown field, then when you tab out
of the field it writes the selected result to Text1 (which can wrap) and
formats the dropdown field as hidden, thus all you see is the wrapped text
in the Text1 field.

I have also added a macro to reset the form which you can run from a toolbar
button. http://www.gmayor.com/installing_macro.htm

Sub ReplaceDropDownFormField()
Dim oFld As FormFields
Dim bProtected As Boolean
Set oFld = ActiveDocument.FormFields

'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If

'Process Dropdown field
oFld("Text1").Result = oFld("Dropdown1").Result
oFld("Dropdown1").Select
Selection.Font.Hidden = True

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub

Sub ResetFormFields()
Dim bProtected As Boolean
Dim oFld As FormFields
Dim i As Long
Set oFld = ActiveDocument.FormFields

'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If

'Format all fields as not hidden
For i = 1 To oFld.Count
oFld(i).Select
Selection.Font.Hidden = False
If oFld(i).Type <> wdFieldFormDropDown Then
oFld(i).Result = ""
End If
Next

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If

End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Hi Graham,
Thank you very much for your reply. I understand your method. The only
downside about it though is that once a selection from the drop down list is
made and the user moves out of the cell, they can't go back and select
something else if they change their mind about their first selection. Am i
right?

I'm happy with your answer though. At least you confirmed that it can't be
done.
Thank you very much again for your help. Much appreciated.
Tendresse
 
G

Graham Mayor

That is the downside, but you could modify the reset macro to act only on
the one field if that was a requirement.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.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