年底了,要写总结要年终奖,大几十个word怎么统计字数成了个问题,查了查怎么遍历word,写了个小循环就成了。
问题是要把所有word打开才行,word太多内存可能要炸吧,考虑到大多数办公机器还是4g,我先溜为敬,233333

Sub test_total()
On Error Resume Next
    Dim doc As Document
    ' 统计段数    ActiveDocument.Paragraphs.Count
    ' 统计字数 ActiveDocument.Words.count
    Dim count, Paragraphs As Integer
    count = 0
    Paragraphs = 0
    For Each doc In Documents
        doc.Activate
        count = count + doc.Range.ComputeStatistics(wdStatisticWords)
        Paragraphs = Paragraphs + doc.Paragraphs.count
        'doc.Close
    Next doc
    MsgBox "总字数"
    MsgBox count
    MsgBox "总段落数"
    MsgBox Paragraphs
End Sub
最后修改:2021 年 01 月 12 日
如果觉得我的文章对你有用,请随意赞赏