Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 03-15-2018, 02:52 AM
gmayor's Avatar
gmayor gmayor is offline Combo Box Content Control: How to update the list throughout the whole document? Windows 10 Combo Box Content Control: How to update the list throughout the whole document? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The short answer is no, however if the content controls are titled and/or tagged you can loop through the content controls and process only those that have a particular title/tag.

You can title/tag the controls if necessary with http://www.gmayor.com/ExtractDataFromForms.htm

If you title the similar fields with a common name e.g. Table1_Name Table2_Name then you can use the following to modify all the fields named like *Table e.g.

Code:
Option Explicit

Sub Macro2()
Dim oRng As Range
Dim oCC As ContentControl
Dim lngCC As Long
Dim iLst As Integer
Dim strListItem As String
Dim strTitle As String
Const strList As String = "C:\path\ccList.txt"
Dim iFile As Integer: iFile = FreeFile
    Set oRng = ActiveDocument.Range
    For lngCC = 1 To oRng.ContentControls.Count
        Set oCC = oRng.ContentControls(lngCC)
        strTitle = oCC.Title
        Debug.Print strTitle
        If strTitle Like "*Name" Then
            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
        End If
    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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Content Control: How to update the list throughout the whole document? How to get a Drop Down List Content Control box to fill in other areas snips1982 Word 2 03-22-2017 03:37 AM
Combo Box Content Control: How to update the list throughout the whole document? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft