View Single Post
 
Old 03-19-2017, 08:40 AM
miguelholandes miguelholandes is offline Windows 10 Office 2013
Novice
 
Join Date: Mar 2017
Posts: 4
miguelholandes is on a distinguished road
Default

Hello,
I have to know how many words I have to translate in code that looks like this: (see attachment).

Now it looks like a mess but I only have to translate the words in black. But there are many long files, so counting the words in black manually would take way too long.


I thought this would do the trick, but no:

Code:
Sub countblackwords()
'
' countblackwords Macro
'
'
Dim wd As Range
Dim CountBlack As Long
    
CountBlack = 0
    For Each wd In ActiveDocument.Words
        If wd.Font.ColorIndex = wdBlack Then
           CountBlack = CountBlack + 1
        End If
    Next wd
    
MsgBox "Number of words in black: " & CountBlack

End Sub
Please, anybody help me?


Much appreciated,

Michiel
Attached Images
File Type: png howmanywordsinblack.png (217.1 KB, 25 views)
Reply With Quote