View Single Post
 
Old 08-29-2017, 04:39 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,370
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 something based on:
Code:
Sub Demo()
Dim i As Long, StrTtl As String, StrTxt As String
StrTtl = "MyTitle": StrTxt = "|"
With ActiveDocument
  On Error Resume Next
  For i = .SelectContentControlsByTitle(StrTtl).Count To 2 Step -1
    With .SelectContentControlsByTitle(StrTtl)(i)
      If InStr(StrTxt, "|" & Trim(.Range.Text) & "|") > 0 Then
        .Range.Text = vbNullString
        .LockContentControl = False
        .Delete
      ElseIf .ShowingPlaceholderText = True Then
        .Delete
      Else
        StrTxt = "|" & Trim(.Range.Text) & StrTxt
        .Range.Text = vbNullString
        .LockContentControl = False
        .Delete
      End If
    End With
  Next
  With .SelectContentControlsByTitle(StrTtl)(1).Range
    StrTxt = Replace(StrTxt, "|" & Trim(.Text), "")
    StrTxt = Left(StrTxt, Len(StrTxt) - 1)
    StrTxt = Replace(StrTxt, "|", ", ")
    .Text = Trim(.Text) & StrTxt
  End With
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote