• Adding FormFields (2003)

    Author
    Topic
    #445653

    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
    I can set the myFF object to the created FormField in the next line, but that just seems so inelegant

    thanks

    Viewing 0 reply threads
    Author
    Replies
    • #1081091

      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”

    Viewing 0 reply threads
    Reply To: Adding FormFields (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: