|
楼主 |
发表于 2019-8-26 10:59
|
显示全部楼层
老师,早上好!
我凑了以下这段代码,您帮忙看看,如果将字典的结果,HZ、SL 按 SL 从大到小排序的结果,另存为一个 word 档?
Sub TeaHorseRoad()
Dim i As Integer
Dim HanZi
Dim Ta As Paragraph
Application.ScreenUpdating = False
ST = Timer
Set HanZi = CreateObject("Scripting.Dictionary")
With ActiveDocument
For Each Ta In .Paragraphs
With Ta.Range.Find
.Execute "[!一-龥^11^13]", , , 1, , , , , , "", 2
End With
j = Ta.Range.Characters.Count
For i = 1 To j
XT = Ta.Range.Characters(i)
If XT <> vbCr Then
If HanZi.Exists(XT) = False Then
HanZi.Add XT, 1
Else
HanZi.Item(XT) = HanZi.Item(XT) + 1
End If
End If
Next
Next
HZ = HanZi.Keys
SL = HanZi.Items
End With
MsgBox "Done!共" & Format(Timer - ST, "0.00") & "秒"
End Sub |
|