|Microsoft Office Word provides a facility to select multiple discontiguous ranges in a document through its user interface (UI). For example, you can select a range of text in a document, and then, while pressing the CTRL key, select another range of text in that same document to create a discontiguous selection (or multiselection). Microsoft Visual Basic for Applications (VBA) macro code and Automation clients have limited programmatic access to the resulting discontiguous selection. This article discusses these limitations. |
Limitations for working with discontiguous selections using the Word object model
You cannot select a discontiguous range programmatically by using the Word object model. A discontiguous selection may only be created by the user in the Word UI.
A Range object cannot contain multiple subranges. Therefore, if the current selection is discontiguous, Selection.Range will return the last subrange that the user selected.
When the user selects multiple discontiguous ranges, the following methods and properties of the Selection object apply to all of the subranges in the user's selection:
method works, but you may experience problems keeping the discontiguous ranges selected.
When the user selects multiple discontiguous ranges, the following members of the Selection object are applied only to the last subrange in the selection:
Certain members of the Selection object generate one of the following run-time error messages when the selection contains multiple discontiguous ranges:
Error message 1
Run-time error 4605:
This method or property is not available because the current selection is a discontiguous selection.
Error message 2
Run-time error 4605:
This command is not available.
The members that generate one of these errors include the following:
There is no way to disable multiselection in Word. However, if you are writing code that works with a selection that the user selects through the UI, you can collapse the selection to the last subrange by using the following:
Article ID: 288424 - Last Review: May 11, 2007 - Revision: 2.2
Microsoft Office Word 2007
Microsoft Office Word 2003
Microsoft Word 2002
Keywords: kbinfo KB288424