View Single Post
 
Old 08-28-2017, 03:52 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
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 Demo()
Dim i As Long, ArrNames, CCtrl As ContentControl
ArrNames = Array("A", "B", "C")
With ActiveDocument
  For i = 0 To UBound(ArrNames)
    On Error Resume Next
    Set CCtrl = .SelectContentControlsByTitle(ArrNames(i))(1)
    On Error GoTo 0
    If CCtrl Is Nothing Then
      .Range.InsertAfter " "
      Set CCtrl = .ContentControls.Add(wdContentControlText, .Range.Characters.Last)
      CCtrl.Title = ArrNames(i)
    End If
    Set CCtrl = Nothing
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote