#1
|
|||
|
|||
Is there a way to export the contents of a Word drop down list?
I have a Word 365 document containing a long drop down list in the form of a Bounding Box. I would like to export the contents of the entire list, make some tweaks, then import the updated list. Is this possible? |
#2
|
||||
|
||||
Are you talking about a Content Control? If so, there isn't an easy way that I know of but you could do it with a couple of macros that would take a bit of work to create.
An easier alternative if you aren't scared by xml is to find the relevant part in the document.xml file and edit it there. Looking at the xml to find the entries of a Dropdown Content Control shows that the list entries follow a simple enough pattern Code:
<w:dropDownList> <w:listItem w:value="Choose an item."/><w:listItem w:displayText="one" w:value="one"/><w:listItem w:displayText="two" w:value="two"/><w:listItem w:displayText="three" w:value="three"/><w:listItem w:displayText="four" w:value="fourish"/><w:listItem w:displayText="five" w:value="and a bit"/><w:listItem w:displayText="six" w:value="keep testing me"/> </w:dropDownList>
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
Bounding Box? What kind of dropdown (formfield, content control, ActiveX control, AutoTextList field, userform object) are you using? There is a 'Bounding Box' display property for content controls in more recent versions of Word, but that isn't supported in Word 2010 & earlier, for example.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
||||
|
||||
If it is a content control list or combo box, you could use my Content Control Tools (Add/Remove/Edit Content Control List Entries) http://www.gmayor.com/insert_content_control_addin.htm to edit the list.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
The type of drop down I am using is content control
|
#6
|
||||
|
||||
Try:
Code:
Sub ExportList() Dim i As Long, StrList As String With Selection.Range If .ContentControls.Count = 0 Then Exit Sub With .ContentControls(1) If .Type = wdContentControlComboBox Or .Type = wdContentControlDropdownList Then For i = 2 To .DropdownListEntries.Count StrList = StrList & Chr(11) & .DropdownListEntries(i).Text & vbTab & .DropdownListEntries(i).Value Next End If End With .Characters.Last.InsertBefore StrList End With End Sub Code:
Sub ImportList() Dim i As Long, StrList As String, Rng As Range, t As Long With Selection.Range If .ContentControls.Count = 0 Then Exit Sub If .Characters.Last = vbCr Then .End = .End - 1 With .ContentControls(1) t = .Type If t = wdContentControlComboBox Or t = wdContentControlDropdownList Then Set Rng = Selection.Range Rng.Start = .Range.End .DropdownListEntries.Clear For i = 1 To UBound(Split(Rng.Text, Chr(11))) .DropdownListEntries.Add Text:=Split(Split(Rng.Text, Chr(11))(i), vbTab)(0), _ Value:=Split(Split(Rng.Text, Chr(11))(i), vbTab)(1) Next .Type = wdContentControlText .Type = t 'Rng.Text = vbNullString End If End With End With End Sub 'Rng.Text = vbNullString can be used to automatically delete the list once it's been imported.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
@macropod - that code worked perfectly. Thank you so much!
|
Tags |
bounding box, export drop down list, word 365 |
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 |
Export Word Drop-Down Content Control to Excel Specific Sheet | nolanthomas32 | Word VBA | 4 | 09-19-2017 06:25 AM |
Drop down list for word doc | Ivylodge | Word | 7 | 08-09-2017 06:15 AM |
Having a Drop-down list in Word referring to an Excel list | celias | Word VBA | 3 | 07-11-2016 11:40 PM |
Populating ComboBox or Drop Down list with contents of a text field | Billy_McSkintos | Word VBA | 1 | 09-13-2011 05:50 AM |