CAUSE
This behavior can occur when all the following conditions are true:
- You are using the Text property on the range.
- The range includes comments.
- You use TextRetrievalMode.IncludeHiddenText set to True to display comment characters.
Comments add a special character. In Word 2000, this character was made visible by setting
TextRetrievalMode.IncludeHiddenText to True. This setting has no effect on comment characters in Word 2002.
WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
For more information about how to use the sample code in this article, click the following article number to view the article in the Microsoft Knowledge Base:
290140
How to run the sample code for the Office XP programs from Knowledge Base articles
To work around this problem, set the
ShowAll property of the Range object to True, as in the following macro example:
Sub A()
Dim rng As Range
Selection.SetRange 0, 8
Set rng = Selection.Range.Duplicate
rng.ShowAll = True
rng.TextRetrievalMode.IncludeHiddenText = True
MsgBox "Selected text is " & rng.Text
End Sub
NoteShowAll is a new Range property. It generates a run-time error if used in Word 2000 or earlier versions.