更新时间:2023-12-05 21:01:34
好吧,我找到了一种方法来做到这一点......不是最漂亮的代码,我相信有更好的方法来做到这一点.但是,由于我对 VB 的了解极其有限,以下内容可以满足我的需求:
Well, I was able to figure out ONE way of doing this....not the prettiest code and I'm sure there's a better way to do this. But, with my extremely limited VB knowledge, the below is working for my needs:
Sub DeleteCCByTag()
Dim oThisdoc As Word.Document
Dim oCC As ContentControl
Dim oCCs As ContentControls
Set oThisdoc = ActiveDocument
Set oCCs = oThisdoc.SelectContentControlsByTag("DCC")
For Each oCC In oCCs
If oCCs.Count > 0 Then
oCC.Delete False
End If
Next
End Sub