ITextRange::SetText method (tom.h)

Sets the text in this range.

Syntax

HRESULT SetText(
  [in] BSTR bstr
);

Parameters

[in] bstr

Type: BSTR

Text that replaces the current text in this range. If null, the current text is deleted.

Return value

Type: HRESULT

The method returns an HRESULT value. If the method succeeds, it returns S_OK. If the method fails, it returns one of the following error codes. For more information about COM error codes, see Error Handling in COM.

Return code Description
E_ACCESSDENIED
Text is write-protected.
E_INVALIDARG
bstr is null.
E_OUTOFMEMORY
Out of memory.

Remarks

ITextRange::SetText replaces the text in the range with the new text. In contrast, TypeText replaces the selection with the text bstr and leaves the selection as an insertion point just following the inserted text, just as if you had typed the text in. For UI selection behavior, see TypeText.

If, after you call ITextRange::SetText, you call ITextRange::GetText, you get back the same text that you set with the ITextRange::SetText method (unless some other range has changed that text in between the calls).

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header tom.h
DLL Msftedit.dll

See also

Conceptual

GetText

ITextRange

Reference

Text Object Model

TypeText