![]() |
|
#8
|
||||
|
||||
|
I don't see where you've previously mentioned that the 'Value' column has anything other than the Display Name (default).
Getting values can be problematic if two or more have the same display names, as there's no vba for directly querying the displayed name's index #. Accordingly, one has to loop through all of them and compare the display name each against each list entry. Subject to that caveat, try: Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim StrOutput As String, CtrlID As String, i As Long
If ContentControl.Type <> wdContentControlDropdownList Then Exit Sub
For Each ContentControl In ContentControls
With ContentControl
If .Type = wdContentControlDropdownList Then
If .Title = "Input" Then
If .Range.Text <> .PlaceholderText Then
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i) = .Range.Text Then
StrOutput = StrOutput & .DropdownListEntries(i).Value & "+"
End If
Next
Else
StrOutput = StrOutput & "N/A" & "+"
End If
End If
End If
If .Title = "Output" Then CtrlID = .ID
End With
Next
StrOutput = Left(StrOutput, Len(StrOutput) - 1)
ContentControls(CtrlID).Range.Text = StrOutput
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Move to next content control
|
cksm4 | Word VBA | 13 | 07-02-2019 07:48 PM |
Hierarchical content control
|
ntjson | Word VBA | 1 | 04-04-2013 12:07 AM |
Content control titles
|
jillapass | Word VBA | 3 | 05-29-2012 06:11 AM |
| Retrieving content control value | jillapass | Word VBA | 4 | 05-24-2012 05:07 AM |
| Calendar control accepts other values | JeJ | Word | 0 | 03-02-2011 03:38 PM |