Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding FormFields (2003)

    ok, anyone know why the following code creates a FormField but then fails to assign it to the myFF object?

    Set myFF = myDoc.FormFields.Add( _
    Range:=myDoc.Tables(6).Cell(iOrigLastRow + 1, 2).Range, _
    Type:=wdFieldFormDropDown)
    I get the FormField but the object is the joyous <nothing>
    I can set the myFF object to the created FormField in the next line, but that just seems so inelegant

    thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding FormFields (2003)

    This is a rather obscure error. The cause is that the cell range includes the end-of-cell marker. You can get around it like this:

    Dim myRng As Range
    ...
    ' Set myRng to cell range
    Set myRng = myDoc.Tables(6).Cell(iOrigLastRow + 1, 2).Range
    ' Exclude end-of-cell marker from range
    myRng.MoveEnd Count:=-1
    ' Create form field
    Set myFF = myDoc.FormFields.Add(Range:=myRng, Type:=wdFieldFormDropDown)
    ' Do something with the formfield object
    myFF.Name = "MyDropdown"

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding FormFields (2003)

    that makes sense actually
    thanks

Posting Permissions

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