I have created Word template with Repeating Section Rontent Control (RSCC) containing other Content Controls. Also I have excel workbook with i
The Word object model has a collection and object for a repeating section content control: RepeatingSectionItems
and RepeatingSectionItem
. The latter has two insert methods, to insert before or after the RepeatingSectionItem
.
Here's a sample that shows how to reference a repeating section content control in a document, get the first or last item and insert a new one after it.
Sub AddRepeatingSection()
Dim cc As Word.ContentControl
Dim repCC As Word.RepeatingSectionItem
Set cc = ActiveDocument.SelectContentControlsByTitle("RepCC").Item(1)
Set repCC = cc.RepeatingSectionItems.Item(1)
'Or to get the last one:
'Set repCC = cc.RepeatingSectionItems.Item(cc.RepeatingSectionItems.Count)
repCC.InsertItemAfter
End Sub