TextSelection Object

Home Page (Objects)OverviewFAQReference

The TextSelection object represents a selection in a text editor window. A selection can be a single point (the insertion point) or a contiguous range of text.

Using the TextSelection object, you can move the insertion point, control which text is selected, and modify the contents of the selection.

The TextSelection object has the following properties and methods:

Properties
Application Parent
BottomLine Text
CurrentColumn TopLine
CurrentLine

Methods
Backspace NewLine
Cancel NextBookmark
ChangeCase PageDown
CharLeft PageUp
CharRight Paste
ClearBookmark PreviousBookmark
Copy ReplaceText
Cut SelectAll
Delete SelectLine
DeleteWhitespace SetBookmark
DestructiveInsert SmartFormat
EndOfDocument StartOfDocument
EndOfLine StartOfLine
FindText Tabify
GoToLine Unindent
Indent Untabify
LineDown WordLeft
LineUp WordRight
MoveTo

You can access the TextSelection object by using the Selection property of the TextDocument object.

Using a Dual Interface to Access This Object

This section about dual interfaces is useful for writing add-ins or automating Developer Studio across processes. This section is not applicable to writing VBScript macros.

The TextSelection object implements the ITextSelection dual interface. Through this interface, add-ins can directly access the members (properties, methods, and events) of this object and can employ early binding to make calls into these members faster at run time.

Add-ins written in Visual C++ can access members of the TextSelection object by using the header files in Vc98\Include\objmodel. However, if you use the Developer Studio Add-in Wizard to create an add-in, the wizard automatically includes these header files in your source code.

The following table shows the header files you need for the TextSelection object:

Header file Description
textauto.h Declares the dual interfaces.
textguid.h Declares the GUIDs used to identify the interfaces.
textdefs.h Declares additional information needed to use the interfaces, such as error IDs and enumerated constants.

Add-ins written in Visual Basic can access members of the TextSelection object by using the Visual Studio '97 Text Editor type library, located in Msdev98\bin\devedit.pkg.

Note   Visual Studio '97 Text Editor is the name that appears in the Visual Basic References dialog box.

See Also   Document object.