SelectionObject Object

SharePoint Designer Developer Reference

Represents the text selected in the page window in Microsoft Office SharePoint Designer.

Interfaces
This object implements the following interfaces

Remarks

Use the selection property of the Document object to return a SelectionObject object. The following example accesses the selection in the active document.

Visual Basic for Applications
Dim objSelection As SelectionObject
Set objSelection = ActiveDocument.Selection

The SelectionObject object contains methods, such as the clear method, that allow you to clear the contents of the selection if the type property for the selection returns "text". The following example clears the contents of the current selection.

Visual Basic for Applications
If ActiveDocument.Selection.Type = "Text" Then _
    ActiveDocument.Selection.Clear

Use the empty method to clear the contents of a selection if the type property returns something other than "text".

Visual Basic for Applications
If ActiveDocument.Selection.Type <> "Text" Then _
    ActiveDocument.Selection.empty

Use the createRange method to create a TextRange object to access additional properties and methods that you can perform on the selected text.

Visual Basic for Applications
Dim objRange As TextRange
Set objRange = ActiveDocument.Selection.createRange

See Also