ITextRange::SetFormattedText method (tom.h)

Sets the formatted text of this range text to the formatted text of the specified range.

Syntax

HRESULT SetFormattedText(
  [in] ITextRange *pRange
);

Parameters

[in] pRange

Type: ITextRange*

The formatted text to replace this range's text.

Return value

Type: HRESULT

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 protected.
E_INVALIDARG
pRange is null.
E_OUTOFMEMORY
Out of memory.

Remarks

If the ITextRange does not belong to the same Text Object Model (TOM) engine, call IUnknown::QueryInterface for an IDataObject interface.

Among the formats typically supported by the IDataObject are CF_TEXT and CF_RTF. In addition, private formats can be used to reference a text solution's own internal rich-text formats. The following Microsoft Visual Basic example uses the FormattedText property to replace the text in range2 with the formatted text in range1.

range2.FormattedText = range1.FormattedText

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

GetDuplicate

GetFormattedText

ITextRange

Reference

Text Object Model