I have a Word document that is used to provide survey responses by users. They then send the word document back to me. The documents contains a number of 2 column tables. In each row, column 1 contains text (the question) and column 2 contains one dropdown list. My code can easily access the text of the chosen response. But I am trying to get to the value associated with the chosen response that I have coded into the dropdown list item when I created the table.
My problem seems to be that I cannot reference the dropdownlist in the cell as I move through each row of the tables.
Private Sub CommandButton1_Click()
Dim Tb1, Tb2 As word.Table
Dim irow, icol, i, j, Tabnum As Integer
Dim Strng As String
Dim RowCount, Responsevalue As Long
Dim File1 As Document
Dim rngDoc As Range
Dim ccMyContentControl As ContentControl
'
'
'First Open Survey Data File
'Display a Dialog Box that allows to select a single file.
'The path for the file picked will be stored in fullpath variable
With Application.FileDialog(msoFileDialogFilePicker)
'Makes sure the user can select only one file
.AllowMultiSelect = False
'Filter to just the following types of files to narrow down selection options
.Filters.Add "Word Files", "*.docx; *.doc; *.docm", 1
'Show the dialog box
.Show
'Store in SurveyData variable
SurveyData = .SelectedItems.Item(1)
Documents.Open SurveyData
Documents(SurveyData).Activate
Tabnum = ActiveDocument.Tables.Count
For i = 1 To Tabnum
' Skip Header Row
For irow = 2 To ActiveDocument.Tables(i).Rows.Count
Strng = ActiveDocument.Tables(i).Cell(irow, 2).Range.Text
' Responsevalue = ActiveDocument.Tables(i).Cell(irow, 2).ContentControl.Range.Result
Let ccMyContentControl = ActiveDocument.Tables(i).Cell(irow, 2).wdContentControlDropdownList
With ccMyContentConrol
For j = 1 To .DropdownListEntries.Count
If .DropdownListEntries(j).Text = Strng Then _
Responsevalue = .DropdownListEntries(j).Value
Else
Responsevalue = 99
MsgBox Responsevalue
Next j
End With
Next irow
Next i
End With
'
' Close Survey Response file
'
End Sub