I have a large document with code samples in. I want to know the word count for all text in font Calibri (Body), regardless of size. I want to ignore Consolas etc.
I have a macro that counts by italic (posted as an example) but can’t get it to run.
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
Any idea how to change this to Consolas?
Modifying your code so you can hopefully understand it, here is a solution that works for me