我創建此代碼以添加找到的項目,並用「[]」或「()」或「{}」括起來。如果在我的文檔中我有「哎呀![哭泣]傷害![哭泣] [笑]」,所以用「[]」括起來的項目將被添加到列表框中,並且有3個,但2個是相同的。我想合併它們。
我該怎麼做?如何刪除列表框中的重複項目
Sub cutsound()
Dim arrs, arrs2, c2 As Variant, pcnt, x2, x3, intItems as Integer
pcnt = ActiveDocument.Paragraphs.Count
arrs = Array("[", "(", "{")
arrs2 = Array("]", ")", "}")
UserForm1.Show False
Application.ScreenUpdating = False
With Selection
.WholeStory
For c2 = 0 To UBound(arrs)
.Find.Execute (arrs(c2))
Do While .Find.Found
.MoveEndUntil Cset:=arrs2(c2), Count:=wdForward
.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
UserForm1.ListBox1.AddItem Selection.Text
.MoveRight Unit:=wdCharacter, Count:=1
.EndKey Unit:=wdStory, Extend:=wdExtend
.Find.Execute
Loop
Next c2
End With
Application.ScreenUpdating = True
End Sub
我會怎麼做呢?對不起,我是新來的。 –