View Single Post
 
Old 09-29-2020, 06:39 AM
Charles Kenyon Charles Kenyon is online now Windows 10 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,118
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Late to the party, but this thread shows up in Google searches. I thought to add another method.

Code:
Sub DropDownValue()
    ' A scratch macro by Charles Kenyon  29 Sept 2020
    ' Assigns value of a DropDown Content Control to a string and reports in message box
    ' https://answers.microsoft.com/en-us/msoffice/forum/all/use-value-not-display-name-of-dropdown-menu-in-vba/0126575d-afa8-457e-aae7-693789f0ba2a
    '
    Dim ccMyCC As ContentControl
    Dim objLe As ContentControlListEntry
    Dim strText As String
    Dim strValue As String
    Set ccMyCC = ActiveDocument.ContentControls(1)
    Let strText = ccMyCC.range.Text
    For Each objLe In ccMyCC.DropdownListEntries
        If objLe.Text = strText Then Let strValue = objLe.Value
    Next
    MsgBox "The value associated with " & strText & " is " & strValue
    Set objLe = Nothing
    Set ccMyCC = Nothing
End Sub
Reply With Quote