This documentation is archived and is not being maintained.

Selection Property (General Extensibility)

Visual Studio .NET 2003

Returns an object representing the current selection on the object.

[Visual Basic .NET]
Public ReadOnly Property Selection() As Object
[Visual Basic 6]
Property Get Selection() As Object
HRESULT __stdcall get_Selection(
   /* [out, retval] */ IDispatch** retVal
object Selection {get;}
[JScript .NET]
public function get Selection() : Object


For the Document object, returns the current selection in the active window associated with this document (or the topmost window of the document if none is active).


Sub SelectionExample()
   ' Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   ' Insert a line of text.
   objSel.Insert("This is a test of the emergency broadcast system.")
   ' Move to the seventh word, select it, and then output it.
   objSel.WordRight(False, 6)
   MsgBox("Seventh word: " & objSel.Text)
End Sub

See Also

Text Property (General Extensibility) | TextSelection Object

Applies To: Document Object | TextDocument Object | TextPane Object | TextWindow Object | Window Object