Microsoft Office Tutorials and References
In Depth Information
Highlighting a Selection in Word 2002/XP
Option explicit¶
' * * * * *¶
Sub InsertAnnotation()¶
'Variable declaration¶
Dim rng As Word.Range¶
Dim cmt As Word.Comment¶
'Optional: prompt to enter the comment text¶
'Comment out the following 7 lines of code¶
'if you do not want to be prompted¶
Dim commentText As String¶
Dim msgPrompt As String¶
Dim msgTitle As String¶
commentText = ""¶
'Change the text in "quotes" to change the prompt¶
msgPrompt = "Enter the comment text"¶
'Change the text in "quotes" to change¶
'the title at the top of the box¶
msgTitle = "Comment text"¶
commentText = InputBox(msgPrompt, msgTitle)¶
If commentText = "" Then Exit Sub¶
'Set the highlight¶
HighlightSelection¶
Set rng = Selection.Range¶
'Create the comment¶
Set cmt = ActiveDocument.Comments.Add(rng, commentText)¶
'Optional: Display the Reviewing task pane¶
'Comment out the following 6 code lines if¶
'forcing display of the task pane is not desired.¶
'If there's more than one task pane, check if the second one¶
'is in Web View; if not, set the Revisions task pane¶
If ActiveWindow.Panes.Count > 1 Then¶
If ActiveDocument.ActiveWindow.Panes(2).View <> wdWebView _¶
Then _¶
ActiveWindow.View.SplitSpecial = wdPaneComments¶
Else¶
'if there's only one pane for the document¶
'display the Revisions task pane¶
ActiveWindow.View.SplitSpecial = wdPaneComments¶
End If¶
End Sub¶
Wrd
Search JabSto ::




Custom Search