Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Editing form fields programmatically (W97, WinNT4)

    <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15> I'm beginning to feel as if I need a new brain here.

    How would one set up a formfield programmatically? I tried to record it, but although it would insert what I wanted (a dropdown field), it would not then let me access it to add items to the list that will drop down!

    Any help gratefully appreciated!
    Beryl M


  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Editing form fields programmatically (W97, WinNT4)

    Beryl,

    THis should help you get started:
    <pre>Dim ffl As FormField

    Set ffl = ActiveDocument.FormFields.Add(Selection.Range, wdFieldFormDropDown)

    With ffl.DropDown
    .ListEntries.Add "A"
    .ListEntries.Add "B"
    End With

    ActiveDocument.Protect wdAllowOnlyFormFields, True</pre>


    The ffl.DropDown will add the Items into the DropDown.

    I tested this on W2K, since I don't have access to W97 here.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Editing form fields programmatically (W97, WinNT4)

    Works fine in Word 97. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editing form fields programmatically (W97, WinNT4)

    Bryan, many thanks, it does indeed work fine in W97, as Sam says!
    Beryl M


  5. #5
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Editing form fields programmatically (W97, WinNT4)

    Great. I'm glad it works in W97 as well.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

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