![]() |
|
#9
|
||||
|
||||
|
Quote:
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
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Creating a reducing drop down list
|
Radders567 | Word VBA | 8 | 06-06-2020 12:41 AM |
| Creating a drop down list that if (a) is selected then (x) happens | mummarochy | Word | 1 | 06-11-2018 10:07 PM |
| Drop down box list based on response to another drop down box | Phideaux | Excel | 16 | 04-13-2018 03:07 AM |
| Help creating a hyperlink drop down list between documents | SconnieGuy91 | Word | 3 | 11-30-2016 05:26 PM |
Having a Drop-down list in Word referring to an Excel list
|
celias | Word VBA | 3 | 07-11-2016 11:40 PM |