View Single Post
 
Old 03-17-2018, 10:50 PM
deepak_fer deepak_fer is offline Windows 10 Office 2016
Novice
 
Join Date: Mar 2018
Posts: 5
deepak_fer is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
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
Hi Graham,

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.
Reply With Quote