Class RepeatingSectionItem (Word VBA)

The class RepeatingSectionItem represents a repeating section item in a content control.

Set

To use a RepeatingSectionItem class variable it first needs to be instantiated, for example

Dim rsi as RepeatingSectionItem
Set rsi = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(Index:=1)

The following procedures can be used to set variables of type RepeatingSectionItem: InsertItemAfter, InsertItemBefore, RepeatingSectionItemColl.Item and ContentControl.RepeatingSectionItems

For Each

Here is an example of processing the RepeatingSectionItem items in a collection.

Dim rsi As RepeatingSectionItem
For Each rsi In ActiveDocument.Range.ContentControls(1).RepeatingSectionItems
	
Next rsi

Delete

Deletes the specified repeating section item.

ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(1).Delete

InsertItemAfter

Adds a repeating section item after the specified item and returns the new item.

You can call this method on repeating section item content controls only. If the ContentControl.AllowInsertDeleteSection property is set to False, this method will return an error.

Dim rsiInsertItemAfter As RepeatingSectionItem
Set rsiInsertItemAfter = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(1).InsertItemAfter()

InsertItemBefore

Adds a repeating section item before the specified item and returns the new item.

You can call this method on repeating section item content controls only. If the ContentControl.AllowInsertDeleteSection property is set to False, this method will return an error.

Dim rsiInsertItemBefore As RepeatingSectionItem
Set rsiInsertItemBefore = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(1).InsertItemBefore()

Parent

Returns an object that represents the parent object of the specified RepeatingSectionItem object.

Dim objParent As Object
Set objParent = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(1).Parent

Range

Returns the range of the specified repeating section item, excluding the start and end tags.

Dim rngRange As Range
Set rngRange = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(1).Range

RepeatingSectionItemColl.Count

Returns a Long that represents the number of repeating section items in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems.Count

RepeatingSectionItemColl.Item

Returns an individual repeating section item.

Syntax : expression.Item (Index)

Index: The index number of the item in the collection.

Dim rsiRepeatingSectionItemColl As RepeatingSectionItem
Set rsiRepeatingSectionItemColl = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems(Index:=1)

RepeatingSectionItemColl.Parent

Returns an object that represents the parent object of the specified RepeatingSectionItemColl object.

Dim objParent As Object
Set objParent = ActiveDocument.Range.ContentControls(1).RepeatingSectionItems.Parent