Microsoft Office Tutorials and References
In Depth Information
Highlighting a Selection in Word 2002/XP
Option explicit¶
' * * * * *¶
Private Const highlightColor As Long = wdBrightGreen¶
'Alternate values: wdPink, wdYellow, wdTurquoise¶
' wdGreen, wdBlue, wdRed, wdTeal, wdDarkRed, wdDarkYellow¶
' wdDarkBlue, wdGray25, wdGray50, wdViolet, wdBlack¶
' * * * * *¶
Sub HighlightSelection()¶
'Check if the selection is only an insertion point (IP)¶
'If it is, extend the range to include the entire word¶
'at the IP, or the one to which it is directly adjacent¶
If Selection.Type = wdSelectionIP Then¶
'Comment out the following line if retaining¶
'a bracket only, and not highlighting an entire word¶
'is desired if there is no selection¶
Selection.Words(1).Select¶
End If¶
Selection.Range.HighlightColorIndex = highlightColor¶
End Sub¶
Wrd
Tip: If you prefer a different highlight color, substitute one of the alternate values for
wdBrightGreen, such as wdRed or wdViolet.
This macro should be assigned to a keyboard shortcut. The example file has the
macro assigned to Alt+H.
Highlighting a Selection in Word 2002/XP
The basis of HighlightSelection may be of interest to Word 2002 users. Word
2002—in contrast to earlier and later versions—does not apply highlighting to
commented text. The selected text is surrounded by very thin brackets, which
are often hard to see. If no text is selected, there is simply a bar marking the
place in the text, which makes it not only difficult to find, but also almost
impossible to position the mouse pointer to display the comment in a tool tip.
The following macro, InsertAnnotation, calls HighlightSelection to help create
visible comments in Word 2002 documents.
View the Appendix to learn how to store this procedure
in a Standard module.
 
Search JabSto ::




Custom Search