View Single Post
 
Old 10-07-2020, 02:22 AM
mbews mbews is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2020
Posts: 6
mbews is on a distinguished road
Default Can Select Case be used to defined the Value of an item in a drop down list?

Hi folks,

I've been piecing together some code from a lot of the helpful resources on here as I'm trying to make more efficient form templates for the company I've recently joined. So far I have a drop down CC from which the Team Leader for any given site visit can be picked. Once this is chosen, their respective mobile number populates a Rich Text CC adjacent (In the drop down properties, TL name is set as Display Name, mobile number is set as Value). Additionally, I currently have, per the code below, a way that the specific Senior Operative(s) for each Team Leader populate a second drop down CC below (this is important as there will be a large quantity of Senior Ops in the finished code, saves people scrolling through them all).

Code:
With CCtrl
  If .Title = "TLName" Then
    If StrOption = .Range.Text Then Exit Sub
    Select Case .Range.Text
      Case "Alan B"
        StrOut = "Kenneth J"
      Case "Alan T"
        StrOut = "Colin L"
      Case Else
        .Type = wdContentControlText
        .Range.Text = ""
        .Type = wdContentControlDropdownList
    End Select
    With ActiveDocument.SelectContentControlsByTitle("SOName")(1)
      .DropdownListEntries.Clear
      For i = 0 To UBound(Split(StrOut, ","))
        .DropdownListEntries.Add Split(StrOut, ",")(i)
      Next
      .Type = wdContentControlText
      .Range.Text = ""
      .Type = wdContentControlDropdownList
    End With
  End If
End With
My issue is that this code defines the SO name as both the Display Name and Value whereas I would like to implement the same method to retrieve the SO mobile number as I did with the Team Leaders. Is there a way the Value can be defined independently of the Display Name, or a simpler way this could be done in general? If need be, I can provide a simplified copy of the template with the code in its entirety (I omitted this as there are other parts of the code irrelevant to this query).

Any help would be greatly appreciated.

Thanks,

Michael
Reply With Quote