|
|
|
|
|
|
Word
|
Color Certain Words for Spell Checking
|
|
Ease of Use
|
Easy
|
Version tested with
|
2003
|
Submitted by:
|
Jacob Hilderbrand
|
Description:
|
Changes font color of pre-defined often wrongly used words.
|
Discussion:
|
While Word has a great spell checker, we may often type the wrong word, such as typing "our" instead of "out" or "or" instead of "of". This macro provides an alternative to the grammar checker.
|
Code:
|
instructions for use
|
Option Explicit
Sub SpellChecker2()
Dim WordCol As Collection
Dim i As Long
Dim StartLine As Long
Dim StartCol As Long
Set WordCol = New Collection
WordCol.Add "our"
WordCol.Add "out"
WordCol.Add "of"
WordCol.Add "or"
For i = 1 To WordCol.Count
StartLine = 0
StartCol = 0
Do
Selection.Find.ClearFormatting
With Selection.Find
.Text = WordCol(i)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
End With
Selection.Find.Execute
If Selection.Range.Text = WordCol(i) Then
If StartLine = 0 Then
StartLine = Selection.Range.Information(wdFirstCharacterLineNumber)
StartCol = Selection.Range.Information(wdFirstCharacterColumnNumber)
Selection.Range.Font.Color = wdColorRed
Else
If StartLine <> Selection.Range.Information(wdFirstCharacterLineNumber) Or _
StartCol <> Selection.Range.Information(wdFirstCharacterColumnNumber) Then
Selection.Range.Font.Color = wdColorRed
Else
Exit Do
End If
End If
End If
Loop
Next i
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst
End Sub
|
How to use:
|
- Open Word.
- Alt + F11 to open the VBE.
- From the Project Explorer select either ThisDocument of Normal depending on where you want to put the code.
- Insert | Module.
- Paste the code in the Code Window that opens to the right.
- Close the VBE (Alt + Q or press the X in the top-right corner).
|
Test the code:
|
- Tools | Macro | Macros...
- Select SpellChecker2 and press Run.
- All the specified words will be colored Red, then just manually check these words to make sure they are really what you wanted to say.
|
Sample File:
|
Word Highlighter.ZIP 6.04KB
|
Approved by mdmackillop
|
This entry has been viewed 213 times.
|
|