我有一个包含代码示例的大文档。我想知道字体Calibri(Body)中所有文本的字数,而不管大小。我想忽略Consolas等通过字体统计Microsoft Word文档中的单词?
我有一个宏,以斜体计(作为示例发布),但无法让它运行。
Sub IgnoreItalics()
Dim lngWord As Long, lngCountIt As Long
lngCountIt = 0
For lngWord = 1 To ActiveDocument.Words.Count
If ActiveDocument.Words(lngWord).Italic Then
lngCountIt = lngCountIt + 1
End If
Next lngWord
MsgBox "Number of non-italic words: " & _
ActiveDocument.BuiltInDocumentProperties("Number of words") -
lngCountIt
End Sub
任何想法如何将此更改为Consolas?
这是什么不运行?你是否收到错误,结果无效等? – Gaffi 2012-03-15 13:36:15
我认为它可能是文档,它是31k字长,所以它最后一次在我的环境下崩溃,认为它可能是代码。 – 2012-03-15 13:47:17
有趣。在你的代码中,你同时使用'ActiveDocument.Words.Count'和'ActiveDocument.BuiltInDocumentProperties(“字数”)''。您是否尝试过在两个位置使用刚刚或另一个? – Gaffi 2012-03-15 13:53:54