Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-08-2022, 11:04 PM
shanshan89 shanshan89 is offline Import list from Excel into drop-down content control in word Windows 10 Import list from Excel into drop-down content control in word Office 2019
Novice
Import list from Excel into drop-down content control in word
 
Join Date: Jul 2022
Posts: 17
shanshan89 is on a distinguished road
Smile

Quote:
Originally Posted by gmaxey View Post
Perhaps:

For lngIndex = 0 To UBound(arrData, 2)
If Not IsNull(UBound(arrData, 2) then

oCC.DropdownListEntries.Add arrData(0, lngIndex), arrData(0, lngIndex)
End If

Next
Thanks Greg. I've incorporated this into my code.

'Get the data. Change sheet name to suit.
arrData1 = fcnExcelDataToArray(strWorkbook, "Simple List")
Set oCC = ActiveDocument.SelectContentControlsByTitle("CC Dropdown List").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)
If Not IsNull(UBound(arrData1, 2)) Then
oCC.DropdownListEntries.Add arrData1(0, lngIndex), arrData1(0, lngIndex)
End If
Next


However, I got an error highlighting the line "oCC.DropdownListEntries.Add arrData1(0, lngIndex), arrData1(0, lngIndex)". The error is Run-time error '6215'
An entry with the same display name already exists - each entry must specify a display name.

I have other dropdown lists which I named them as arrData2, arrData3 etc to create a few simple dropdown list but I didn't have that error earlier.

Able to advise?

Thanks.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Import list from Excel into drop-down content control in word How to import list from Excel into drop-down list into word ahw Word VBA 43 02-28-2020 08:11 PM
Import list from Excel into drop-down content control in word Assigning Macro to Drop Down list Content Control aussiew Word VBA 5 03-10-2019 02:55 PM
Import list from Excel into drop-down content control in word Export Word Drop-Down Content Control to Excel Specific Sheet nolanthomas32 Word VBA 4 09-19-2017 06:25 AM
Import list from Excel into drop-down content control in word 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:14 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