Forum Discussion

leejohnc's avatar
leejohnc
Copper Contributor
Mar 29, 2024

Dropdown list

New to this.   I'm trying to use modern (not legacy) dropdown lists, which stores a friendly label, with an integer value.  On selection, another field will contain the summed-up values calculated from multiple dropdown lists.

 

    • leejohnc's avatar
      leejohnc
      Copper Contributor

      Doug_Robbins_Word_MVP 

       

      Yes, I was able to figure it out, thanks.  Not my finest work, but hopefully makes the point.

       

       

       

       

       

       

       

       

      Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
      
      Dim doc As Document Set doc = ActiveDocument Dim dd As FormField Dim cc01As ContentControl
      Dim Txt1 As FormField Dim TotalInt As Integer Dim oDLE As ContentControlListEntry
      Dim Question01Answer As Integer
      
      Set cc01 = doc.SelectContentControlsByTag("Question01").Item(1)
      
      For Each oDLE In cc01.DropdownListEntries If oDLE.Text = cc01.Range.Text Then Question01Answer = oDLE.Value End If Next
      
      Dim selectedValue As String TotalInt = Question01Answer
      
      Set Txt1 = doc.FormFields("Text1")
      
      Txt1.TextInput.Default = TotalInt 
      
      doc.Fields.Update
      
      End Sub

       

Share