Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 01-18-2019, 01:59 PM
macropod's Avatar
macropod macropod is offline Is there a way to export the contents of a Word drop down list? Windows 7 64bit Is there a way to export the contents of a Word drop down list? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
and:
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
It is assumed the content control is followed by a paragraph break, which must be included in the selection for export. The content control and entry list must be re-selected for import. Do not delete the exported tabs unless the entire entry is deleted; any new entries must likewise contain a tab. The commented-out:
'Rng.Text = vbNullString
can be used to automatically delete the list once it's been imported.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
bounding box, export drop down list, word 365



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to export the contents of a Word drop down list? How to import list from Excel into drop-down list into word ahw Word VBA 43 02-28-2020 08:11 PM
Is there a way to export the contents of a Word drop down list? 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
Is there a way to export the contents of a Word drop down list? Having a Drop-down list in Word referring to an Excel list celias Word VBA 3 07-11-2016 11:40 PM
Is there a way to export the contents of a Word drop down list? Populating ComboBox or Drop Down list with contents of a text field Billy_McSkintos Word VBA 1 09-13-2011 05:50 AM

Other Forums: Access Forums

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