View Single Post
 
Old 11-14-2018, 03:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit 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

A dropdown list in Word is less dynamic than a file open dialogue, since you would need to repopulate the list every time you access it to ensure it remains current. Also, adding more files to the list wouldn't add them to the folder. To populate and keep refreshed your content control with such a list you might use code like the following in your document's 'ThisDocument' code module:
Code:
Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl)
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String
strDocNm = ActiveDocument.FullName
strFolder = ActiveDocument.Path
strFile = Dir(strFolder & "\*.doc", vbNormal)
With CCtrl
  .DropdownListEntries.Clear
  .Type = wdContentControlText
  .Range.Text = ""
  .Type = wdContentControlDropdownList
  While strFile <> ""
    If strFolder & "\" & strFile <> strDocNm Then
      .DropdownListEntries.Add strFile
    End If
    strFile = Dir()
  Wend
End With
Application.ScreenUpdating = True
End Sub
The above code populates the content control with a list of documents in found in the same folder as the document containing your content control.

To retain the previous selection, omit:
Code:
  .Type = wdContentControlText
  .Range.Text = ""
  .Type = wdContentControlDropdownList
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote