Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Trying to write vba code to add and delete repeating item section for specifically named RSCC.

The following code works for adding but cannot figure out how to delete

Is it possible to add Repeating Section Content Control section with VBA?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
417 views
Welcome To Ask or Share your Answers For Others

1 Answer

To delete repeating item section for specifically named RSCC just edit the code you found in the other question.

Set cc = ActiveDocument.SelectContentControlsByTitle("RepCC").Item(1)
'to delete the first RepeatingSectionItem
cc.RepeatingSectionItems.Item(1).Delete
'to delete all but the first RepeatingSectionItem
Dim index As Long
For index = cc.RepeatingSectionItems.Count To 2 Step -1
  cc.RepeatingSectionItems.Item(index).Delete
Next index
'to delete the entire ContentControl
cc.Delete

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...