|
Private Sub CommandButton1_Click()
Dim p As Paragraph, Q As Range, d As Object, sr$, tr$
Set d = CreateObject("Scripting.Dictionary")
For Each p In ActiveDocument.Paragraphs
With p.Range
If InStr(.Text, ":") Then
x = InStr(.Text, ":")
.Start = .Start + x: .End = .End - 1
sr = .Text
If Not d.Exists(Left(p.Range.Text, x)) Then
d(Left(p.Range.Text, x)) = sr
Else
d(Left(p.Range.Text, x)) = d(Left(p.Range.Text, x)) & ";" & sr
End If
End If
End With
Next
k = d.keys: t = d.items
For i = 0 To d.Count - 1
tr = tr & k(i) & t(i) & vbCr
Next
ActiveDocument.Content.InsertAfter tr
MsgBox "完成,OK!"
End Sub |
|