Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Text Object Model

Feedback

In this article

This section contains information about the programming elements used with the Text Object Model (TOM).

The TOM defines a substantial set of text manipulation interfaces. Text solutions such as Microsoft Word and rich edit controls support the TOM feature set. TOM was greatly influenced by WordBasic (the programming language used for Word) and it is easy to use from Microsoft Visual Basic for Applications (VBA). This compatibility has several advantages:

  • Code can migrate fairly easily from one solution to another.
  • One language can be used to share text information between different text engines.
  • It reduces the need for documentation and code compared to the separate low-level Component Object Model (COM) and VBA interfaces.

However, it can be less efficient for C/C++ purposes than the use of more general lower level COM interfaces.

TOM is a straightforward set of interfaces to implement for its primary text solutions, Word and rich edit controls. However, for applications that place minor emphasis on text, it is better to provide TOM interfaces by transferring the text to an edit control that supports TOM. Since rich edit controls ship with Microsoft operating systems, they are the standard means of obtaining TOM functionality.

Overviews

TopicContents
About Text Object ModelThe top-level Text Object Model (TOM) object is defined by theITextDocument interface, which has methods for creating and retrieving objects lower in the object hierarchy.
Using The Text Object ModelThe code samples in this document show various aspects of using the Text Object Model (TOM).

Interfaces

TopicContents
ITextDocumentTheITextDocument interface is the TOM top-level interface, which retrieves the active selection and range objects for any story in the document whether active or not. It enables the application to:
  • Open and save documents.
  • Control undo behavior and screen updating.
  • Find a range from a screen position.
  • Get anITextStoryRanges story enumerator.

When to Implement
Applications typically do not implement theITextDocument interface. Microsoft text solutions, such as rich edit controls, implementITextDocument as part of their TOM implementation.
When to Use
Applications can retrieve anITextDocument pointer from a rich edit control. To do this, send anEM_GETOLEINTERFACE message to retrieve anIRichEditOle object from a rich edit control. Then, call the object'sIUnknown::QueryInterface method to retrieve anITextDocument pointer.
ITextFontTOM rich text-range attributes are accessed through a pair of dual interfaces,ITextFont andITextPara.
ITextParaTOM rich text-range attributes are accessed through a pair of dual interfaces,ITextFont andITextPara.
ITextRangeTheITextRange objects are powerful editing and data-binding tools that allow a program to select text in a story and then examine or change that text.
ITextSelectionA text selection is a text range with selection highlighting.
ITextStoryRangesThe purpose of theITextStoryRanges interface is to enumerate the stories in anITextDocument.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?