![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
||||
|
||||
|
You could use a macro to update them. If you make a list of the entries in a text file - one per line - omitting the prompt text, the following macro will replace all the lists in all the dropdown content controls in a selection with the items in the named text file
Code:
Sub Macro1()
Dim oRng As Range
Dim oCC As ContentControl
Dim lngCC As Long
Dim iLst As Integer
Dim strListItem As String
Const strList As String = "C:\path\ccList.txt"
Dim iFile As Integer: iFile = FreeFile
Set oRng = Selection.Range
For lngCC = 1 To oRng.ContentControls.Count
Set oCC = oRng.ContentControls(lngCC)
If oCC.Type = wdContentControlComboBox Or _
oCC.Type = wdContentControlDropdownList Then
'leave the prompt text and delete the rest
For iLst = oCC.DropdownListEntries.Count To 2 Step -1
oCC.DropdownListEntries(iLst).Delete
Next iLst
End If
'add the new list from a text file
Open strList For Input As #iFile
Do Until EOF(1)
Line Input #1, strListItem
oCC.DropdownListEntries.Add strListItem
Loop
Close #iFile
Next lngCC
lbl_Exit:
Set oRng = Nothing
Set oCC = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com Last edited by gmayor; 03-13-2018 at 09:00 AM. |
|
#2
|
|||
|
|||
|
Quote:
Thank you for the code. Can I do this for multiple combo boxes? I mean, all 5 boxes in the table will have different content. All the 5 boxes in the table are named/ titled differently. If copy/ paste this table multiple times, then I have one particular named box in each of those table. How can I edit this code such that it updates that particular box in all the tables? I hope you understand what i am trying to say.. Tried my best to explain.. |
|
#3
|
|||
|
|||
|
Quote:
Can this list be embedded into the document or in the macro itself? The reason is, I want to make this document future proof.. So when i send this to the client, I also need to send the notepad list. So i was thinking if its possible to embed that list, so that there is no need to send additional stuff that may/ may not confuse them. Thanks for your patience and help. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to get a Drop Down List Content Control box to fill in other areas
|
snips1982 | Word | 2 | 03-22-2017 03:37 AM |
Multi-column combo box content control?
|
sugarjay | Word | 1 | 03-21-2017 07:20 PM |
| Combo Box Content Control Calculate on selection help | ciresuark | Word | 0 | 03-06-2015 01:49 PM |
| Word 2010 Content Control help - Combo Boxes vs Drop Down List | proghy | Word | 1 | 09-16-2014 02:01 PM |
| Download Content Control List | cjacob28 | Word | 0 | 06-26-2011 11:23 PM |