none
Problem reading value from a FormField (Dropdown) in Word 2010 document using VBA RRS feed

  • Question

  • Problem:

    We have a word 2010 document that has a drop-down listing several items, the document is being parsed by an access application using VBA. When the function parses the document we noticed that the following line below returns a Null Value instead of the value from the drop-down. Here is the line of code:

    strOffice= ActiveDocument.FormFields("Office").Dropdown.Value

    Whereas this works fine:

    strDescription = ActiveDocument.FormFields("fldPosDescription").Result

    We have no idea why we cannot read the selected value from the dropdown??

    Any help is most appreciated.

    BTW: We are using WORD 2010 and selected a Non-Legacy Drop-Down List Control from the Ribbon.

    Thanks very much!

    Eric




    Thursday, October 29, 2015 3:33 PM

Answers

  • Hi,

    >>Yes we did, same problem. :-( BTW with the drop-down form field legacy it works but with the drop-down ActiveX control it does not work and we need the ActiveX control because on this control there are no limitations on the amount of items one can enter.  <<

    As far as I know, there are Combo box and List box ActiveX control in Word. And it is different to developing with ActiveX control with form field in Word. We need to loop the inline shapes get the instance of ActiveX control.

    Here is an example that get the value of ComboBox1 ActiveX control:

    For Each aShape In ActiveDocument.InlineShapes
        If Not IsNull(aShape.OLEFormat) Then
            If aShape.OLEFormat.Object.Name = "ComboBox1" Then
                 Debug.Print ActiveDocument.InlineShapes.Item(1).OLEFormat.Object.Value
            End If
        
        End If
     Next aShape
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 2:59 AM
    Moderator

All replies

  • Problem:

    We have a word 2010 document that has a drop-down listing several items, the document is being parsed by an access application using VBA. When the function parses the document we noticed that the following line below returns a Null Value instead of the value from the drop-down. Here is the line of code:

    strOffice= ActiveDocument.FormFields("Office").Dropdown.Value

    Whereas this works fine:

    strDescription = ActiveDocument.FormFields("fldPosDescription").Result

    We have no idea why we cannot read the selected value from the dropdown??

    Any help is most appreciated.

    BTW: We are using WORD 2010 and selected a Non-Legacy Drop-Down List Control from the Ribbon.

    Have you tried:

        strOffice= ActiveDocument.FormFields("Office").Result

    ?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Thursday, October 29, 2015 4:19 PM
  • Yes we did, same problem. :-( BTW with the drop-down form field legacy it works but with the drop-down ActiveX control it does not work and we need the ActiveX control because on this control there are no limitations on the amount of items one can enter. Thanks for helping us on that issue.
    Thursday, October 29, 2015 4:24 PM
  • Yes we did, same problem. :-( BTW with the drop-down form field legacy it works but with the drop-down ActiveX control it does not work and we need the ActiveX control because on this control there are no limitations on the amount of items one can enter. Thanks for helping us on that issue.

    I don't have Word 2010, so I'm trying to recreate your situation using Word 2013.  I want to verify:  did you add Dropdown List Content Control, or an ActiveX Combo Box control, or something else?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Thursday, October 29, 2015 5:32 PM
  • Hi,

    >>Yes we did, same problem. :-( BTW with the drop-down form field legacy it works but with the drop-down ActiveX control it does not work and we need the ActiveX control because on this control there are no limitations on the amount of items one can enter.  <<

    As far as I know, there are Combo box and List box ActiveX control in Word. And it is different to developing with ActiveX control with form field in Word. We need to loop the inline shapes get the instance of ActiveX control.

    Here is an example that get the value of ComboBox1 ActiveX control:

    For Each aShape In ActiveDocument.InlineShapes
        If Not IsNull(aShape.OLEFormat) Then
            If aShape.OLEFormat.Object.Name = "ComboBox1" Then
                 Debug.Print ActiveDocument.InlineShapes.Item(1).OLEFormat.Object.Value
            End If
        
        End If
     Next aShape
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 2:59 AM
    Moderator
  • Thanks Fei, we will try this out later this morning. I appreciate your help on this.
    Friday, October 30, 2015 6:41 AM
  • Yes we did, same problem. :-( BTW with the drop-down form field legacy it works but with the drop-down ActiveX control it does not work and we need the ActiveX control because on this control there are no limitations on the amount of items one can enter. Thanks for helping us on that issue.

    An alternative would be to use content controls instead of either the formfields or the ActiveX controls. Do note that, if the document is to be used on Macs, you can't use either content controls or ActiveX controls.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, October 30, 2015 9:18 AM