年底了,要写总结要年终奖,大几十个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
4 条评论
word高手,这个评论框好有趣~
个站商店是你开的吗,厉害了老哥
我,优秀员工,打钱
哎,我可能都没年终奖,年会年前都不开了