Article ID: 286850
Article Last Modified on 1/29/2007
APPLIES TO
- Microsoft Office Word 2003
- Microsoft Word 2002 Standard Edition
This article was previously published under Q286850
SYMPTOMS
When you run a Visual Basic for Applications macro that uses ranges of text in Microsoft Word, the results of the macro may vary from running the same macro in Word 2000 when there are comments in the ranges.
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.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Additional query words: VBE VBA WD2002 WD2003
Keywords: kbbug kbnofix KB286850