ITextRange::SetText method

Sets the text in this range.

Syntax


HRESULT SetText(
  [in]  BSTR bstr
);

Parameters

bstr [in]

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 codeDescription
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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Tom.h

DLL

Msftedit.dll

See also

Reference
ITextRange
GetText
TypeText
Conceptual
Text Object Model

 

 

Community Additions

ADD
Show:
© 2014 Microsoft