Quote:
Originally Posted by killoffski
ok thanks i will try this, i cant see within the code how it tells the content box to change the words, for instance one of the options is 9001 4.1 Understanding the Organization and its context and i want it to display 9001:2015 - 4.1 when i select it.
|
Neither of the options will do this as you have added text to the string.
Provided it is the same added text each time i.e. ':2015 - ' then the following macro will mofify your list to do that (at least as far as the list was shown in the original screen shot)
Code:
Sub Macro1()
Dim oCC As ContentControl
Dim i As Integer
Dim strValue As String, strText As String
Dim Coll As Collection
Set oCC = ActiveDocument.SelectContentControlsByTitle("Quality 2015").Item(1)
Set Coll = New Collection
With oCC.DropdownListEntries
For i = 2 To .Count
strText = .Item(i).Text
strValue = onlyDigits(.Item(i).Text)
strValue = Replace(strValue, "9001", "9001:2015 - ")
Coll.Add Trim(strText) & "|" & strValue
Next i
.Clear
.Add "Choose an item", ""
For i = 1 To Coll.Count
.Add Split(Coll.Item(i), "|")(0), Split(Coll.Item(i), "|")(1)
Next i
End With
End Sub
Private Function onlyDigits(s As String) As String
Dim retval As String
Dim i As Integer
retval = ""
For i = 1 To Len(s)
If Mid(s, i, 1) >= "0" And Mid(s, i, 1) <= "9" _
Or Mid(s, i, 1) = "." Then
retval = retval + Mid(s, i, 1)
End If
Next
onlyDigits = retval
End Function