Drop-down form fields

L

LynnR

Is there a way around the character limitation when using
a drop-down form field...I have a requirement for a drop-
down with long entries for each item. Word cuts off the
type after about 25 characters. Is there an easy way
programatically to create my own drop-down box....help is
appreciated. Best regards
 
C

Charles Kenyon

You could call up an on-exit macro that (1) hides the drop-down field and
(2) uses the contents of the field to choose text to insert or display,
possibly from AutoText.

You could actually not hide the field but simply have it be the beginning of
your text and have the rest inserted at a bookmark following the field
depending on the contents of the field. You would be unprotecting and
reprotecting the form and inserting text in a bookmark without deleting the
bookmark. These are both slightly tricky but there are code examples of both
available at the MVP FAQ site.

There is probably a better way but nothing occurs to me.
 
L

LynnR

I experimented with creating the drop-down in vba and it
works without having to unprotect the document, except...
the Range:=Yadayada.Range (Start:=0, End:=0) puts the drop-
down list at the beginning of the page (see start,end) I
understand what and why the code is doing that, I just
don't have the know how to set the range (if range is
correct in this instance) as a bookmarked form field.

When I tab from a prior form field, using an "entry" macro
to the field where I really, really want the list to
appear, it instead appears at the top/left/start of the
form document and I understand the range command is
controlling that... I feel I can get this to work if I can
modify the code to see the book marked field being tabbed
into....any suggestions please...best regards (see sample
of the code below)

Sub Dropdown()
Set ffield = ActiveDocument.FormFields.Add( _
Range:=ActiveDocument.Range(Start:=0, End:=0), _
Type:=wdFieldFormDropDown)
With ffield
.Name = "No1"
With .Dropdown.ListEntries
.Add Name:="Text1"
.Add Name:="Text2"
.Add Name:="Text3"
End With
End With
 
C

Charles Kenyon

You would be inserting text, not a field at a predetermined bookmark
location and you do need to unprotect the document to do that. You can
either have the text directly in your macro, or you can store it in
AutoText. My preference is to store it in AutoText because it makes the
macro much less bulky and AT is easier (for me) to edit than is text
embedded in a macro. That is, the first part of the information you want is
in the drop-down. That is used by the macro to decide what (if any) text is
to follow.

You probably could use the bookmark from the drop-down field for positioning
except that then your choice would be final. If you add a separate bookmark
following the field you can put your insertion inside the bookmark. If the
selection in the drop-down changes, that text can be replaced with the same
macro.
 

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