View Single Post
 
Old 10-16-2022, 05:29 AM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
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

For example, assuming you first select all the options:
Code:
Sub AddComboBox()
Application.ScreenUpdating = False
Dim objCC As ContentControl, StrTxt As String, i As Long
With Selection.Range
  If InStr(.Text, "[") = 0 Then Exit Sub
  If InStr(.Text, "]") = 0 Then Exit Sub
  If .Characters.Last <> "]" Then .MoveEndUntil "]", wdBackward
  StrTxt = .Text
  StrTxt = Replace(StrTxt, "]", "")
  .Text = vbNullString
  Set objCC = .ContentControls.Add(wdContentControlComboBox)
  With objCC
    .SetPlaceholderText Text:="Please make a selection"
    For i = 1 To UBound(Split(StrTxt, "["))
      .DropdownListEntries.Add Split(StrTxt, "[")(i)
    Next
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote