Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Dec 2002
    Thanked 0 Times in 0 Posts

    specify formfield parameters (97, SR2)

    Hi, all, Long-time lurker, first-time poster here...

    I have a document that is protected for forms. It contains a table for logging data. Each table cell contains a text, date, or dropdown list formfield with a maximum length. I want the user to be able to add rows of the same blank fields by clicking a button. My routine will then relock the document so the user may tab through and fill in the new rows. Through VBA, I can unlock the document, add x number of rows, and add the correct type of formfield to each new cell with statements like this:

    Selection.FormFields.Add Range:=Selection.Range, Type:= _wdFieldFormTextInput

    How do I specify the maximum length and any default values for these formfields? How do I create the selection list for my dropdown field?

    Thanks for any advice!


  2. #2
    Super Moderator
    Join Date
    Dec 2000
    New York, NY
    Thanked 29 Times in 27 Posts

    Re: specify formfield parameters (97, SR2)


    The code sample you've posted looks like it will create an ordinary text input formfield, not a dropdown-type formfield.
    To create a dropdown formfield and add a selection list, try code like this:

    <pre>Public Sub AddDropdownFormField()

    Dim objDropdown As FormField

    Set objDropdown = _
    Selection.FormFields.Add(Range:=Selection.Range, Type:=wdFieldFormDropDown)

    With objDropdown
    .DropDown.ListEntries.Add "First Entry"
    .DropDown.ListEntries.Add "Second Entry"
    .DropDown.ListEntries.Add "Third Entry"
    End With

    Set objDropdown = Nothing

    End Sub

    - this does not include a maximum length because you can't set the maximum length for a dropdown formfield (not sure how to set that value for a text input formfield).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts