统计出Word中一篇文档有多少个不同的字
Sub CharCount()
Dim myCol As New Collection
Dim mystring As String, i As Long
Dim mystr As String
On Error Resume Next
mystring = ActiveDocument.Content
For i = 1 To Len(mystring)
If Mid(mystring, i, 1) Like "[ 一-﨩]" Then
myCol.Add Mid(mystring, i, 1), Mid(mystring, i, 1)
End If
Next
Dim j
For j = 1 To myCol.Count
mystr = mystr & myCol.Item(j) & vbCrLf
Next
Documents.Add.Content = "简体汉字是:" & myCol.Count & "个" _
& vbCrLf & mystr
End Sub