Re: How to search for colors in MS Word?
Murgi wrote:
> Does anybody know how to count the bytes all words of a particular
> color? My client wants me to do exactly like that. I am no MS Word
> guru and don't know how to gather all words of one color in one
> single file.
The following macro will do it, or close to it (it counts the characters,
not the bytes)
Usage:
(1) Copy this macro into your normal.dot (ALT + F11...)
(2) In your document, select some text with the color you want to count.
(3) Run the macro
(4) A message box tells you how many characters of that color there are in
the document
# It catches all text in the document, including footnotes, textboxes, etc.
# No warranties, not suitable for any particular purpose, etc. etc. Tested
only on Word 2000.
--
Regards,
Ryan Ginstrom
' =========================
Sub GetColorCharCount()
Dim ColorType As Long
ColorType = Selection.Font.Color
Dim ColorCount As Long
ColorCount = 0
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
Dim oChar As Object
For Each oChar In oStory.Characters
If oChar.Font.Color = ColorType Then
ColorCount = ColorCount + 1
End If
Next oChar
Next oStory
MsgBox "There are a total of " & _
CStr(ColorCount) & _
" characters with the specified color in this document.", _
vbOKOnly, _
"ColorCount"
End Sub
Fnews-brouse 1.9(20180406) -- by Mizuno, MWE <mwe@ccsf.jp>
GnuPG Key ID = ECC8A735
GnuPG Key fingerprint = 9BE6 B9E9 55A5 A499 CD51 946E 9BDC 7870 ECC8 A735