![]() |
|
#5
|
|||
|
|||
|
Quote:
I have another issue with the simple word dropdown list. I have 3 tables with 3 identical word dropdown lists that needs to be updated from a particular excel sheet e.g. 'Sheet 1'. In order for the fields in all 3 word dropdown lists to be updated correctly when I update 'Sheet 1' , I have to create 3 drop-down lists, each with a unique content control name e.g. arrData1 with content control title 'Dropdown List 1', arrData2 with content control title 'Dropdown List 2', and arrData3 'Dropdown List 3 (see extract of code below). However, the user may not necessarily be using all 3 tables. He can delete 2 tables, but he will minimally fill in at least one of the 3 tables. If the tables (with the content controls) are deleted in the word document main page, there will be an error because some of the codes for the content control dropdown list written in the visual basic editor cannot be found in the word document main page. Is there any method to modify the code such that if any of the codes for the dropdown list (e.g. Dropdown List 1 and Dropdown List 3) is written in the visual basic editor but cannot be found in the word document main page, to ignore this error? Apologies for the long description and hope this is understandable! arrData1 = fcnExcelDataToArray(strWorkbook, "Sheet 1") Set oCC = ActiveDocument.SelectContentControlsByTitle("Dropd own List 1").Item(1) 'Populate the CC If oCC.DropdownListEntries.Item(1).Value = vbNullString Then 'Assumes the CC has a placeholder "Choose Item" entry with no defined value. _ Preserve the placeholder entry. For lngIndex = oCC.DropdownListEntries.Count To 2 Step -1 oCC.DropdownListEntries.Item(lngIndex).Delete Next lngIndex Else 'Assumes no placeholder entry. Simple clear list. oCC.DropdownListEntries.Clear End If For lngIndex = 0 To UBound(arrData1, 2) oCC.DropdownListEntries.Add arrData1(0, lngIndex), arrData1(0, lngIndex) Next arrData2 = fcnExcelDataToArray(strWorkbook, "Sheet 1") Set oCC = ActiveDocument.SelectContentControlsByTitle("Dropd own List 2").Item(1) 'Populate the CC If oCC.DropdownListEntries.Item(1).Value = vbNullString Then 'Assumes the CC has a placeholder "Choose Item" entry with no defined value. _ Preserve the placeholder entry. For lngIndex = oCC.DropdownListEntries.Count To 2 Step -1 oCC.DropdownListEntries.Item(lngIndex).Delete Next lngIndex Else 'Assumes no placeholder entry. Simple clear list. oCC.DropdownListEntries.Clear End If For lngIndex = 0 To UBound(arrData2, 2) oCC.DropdownListEntries.Add arrData2(0, lngIndex), arrData2(0, lngIndex) Next arrData3 = fcnExcelDataToArray(strWorkbook, "Sheet 1") Set oCC = ActiveDocument.SelectContentControlsByTitle("Dropd own List 3").Item(1) 'Populate the CC If oCC.DropdownListEntries.Item(1).Value = vbNullString Then 'Assumes the CC has a placeholder "Choose Item" entry with no defined value. _ Preserve the placeholder entry. For lngIndex = oCC.DropdownListEntries.Count To 2 Step -1 oCC.DropdownListEntries.Item(lngIndex).Delete Next lngIndex Else 'Assumes no placeholder entry. Simple clear list. oCC.DropdownListEntries.Clear End If For lngIndex = 0 To UBound(arrData3, 2) oCC.DropdownListEntries.Add arrData3(0, lngIndex), arrData3(0, lngIndex) Next |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to import list from Excel into drop-down list into word
|
ahw | Word VBA | 43 | 02-28-2020 08:11 PM |
Assigning Macro to Drop Down list Content Control
|
aussiew | Word VBA | 5 | 03-10-2019 02:55 PM |
Export Word Drop-Down Content Control to Excel Specific Sheet
|
nolanthomas32 | Word VBA | 4 | 09-19-2017 06:25 AM |
How to get a Drop Down List Content Control box to fill in other areas
|
snips1982 | Word | 2 | 03-22-2017 03:37 AM |
| Word 2010 Content Control help - Combo Boxes vs Drop Down List | proghy | Word | 1 | 09-16-2014 02:01 PM |