以下代码成功删除了选定的 RSCC,但始终阻止删除第一个 RSCC。
Dim cc As ContentControl
If Selection.Information(wdInContentControl) Then
Set cc = Selection.ParentContentControl
If Not cc.Type = wdContentControlRepeatingSection Then
Do Until cc.Type = wdContentControlRepeatingSection
Set cc = cc.ParentContentControl
Loop
End If
Dim index As Long
For index = 1 To cc.RepeatingSectionItems.Count
If Selection.Range.InRange(cc.RepeatingSectionItems(index).Range) Then
If index > 1 Then
cc.RepeatingSectionItems(index).Delete
Else
MsgBox Prompt:="You cannot delete this.", Title:="Error"
End If
Exit For
End If
Next index
End If
我的目标是能够删除任何选定的 RSCC,但如果还剩下任何一个 RSCC,则不能。
换句话说,如果我有三个 RSCC (1,2,3),而不是总是保护第 1 节,如果我要删除第 1 节和第 3 节,我想保护第 2 节,或者如果第 1 节和第 2 节,我想保护第 3 节被删除。