Microsoft KB Archive/292138

= Macro does not return all selected text as expected in Word =

Article ID: 292138

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition

-



This article was previously published under Q292138



SYMPTOMS
In Microsoft Office Word, when you use the Text property of the Selection object to return selected non-contiguous text with a Microsoft Visual Basic for Applications (VBA) macro, not all of the selected text is returned to the Immediate window of the Visual Basic Editor as expected.



CAUSE
This behavior occurs when you use the CTRL key and the mouse to select non-contiguous strings of text, and then attempt to programmatically use or view the selected text in the Immediate window by running a macro similar to the following: Sub ProccessMultiSelect

Debug.Print Selection.Text

End Sub Only the last text selection is stored in the Selection.Text property. Earlier selections are overwritten each time a new selection is made. Therefore, only the last can be returned to the Immediate window.



WORKAROUND
To work around this issue, select only one contiguous text string each time that you use the Text property of the Visual Basic Selection object.

Additional query words: prb WD2002 WD2003

Keywords: kbprb KB292138

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.