The new vbAccelerator Site - more VB and .NET Code and Controls
 Source Code
1 ActiveX Controls &nbsp

RichEdit 3.0 Text Object Model (TOM) Interface Sample


Using the vbAccelerator Control With the Version 3.0 of RichEd20.DLL

vbAccelerator RichEdit TOM Demonstration Project

Download Code
VB5 code Download the RichEdit 3.0 Text Object Model Demonstration (20kb)

&nbsp Before you Begin &nbsp
&nbsp This project requires the vbAccelerator RichEdit Control. Make sure you have loaded and registered this before trying the project. &nbsp
&nbsp This project requires the SSubTmr.DLL component. Make sure you have loaded and registered this before trying the project. &nbsp
&nbsp The source code project requires the IShellFolder Extended Type Library v1.2 (ISHF_Ex.TLB) when running in the IDE. Make sure you have downloaded and registered this before trying the project. &nbsp
&nbsp The source code project requires the Shell Extension Type Library v1.01 (SHLEXT.TLB) when running in the IDE. Make sure you have downloaded and registered this before trying the project. &nbsp

This sample demonstrates a class which provides a Text Object Model (TOM) interface from version 3.0 of the RichEd20.DLL.

The Microsoft® Text Object Model (TOM) defines a set of text manipulation interfaces that are supported by text solutions such as Microsoft Word and the rich edit control. TOM has many methods and a powerful but simple COM object model, making it easy to use from VB and VBA and offering substantial text processing power.

Note to get RichEdit version 3.0 you either need to be running Win2000 or you need to download the Microsoft Systems Installer (MSI) redistributable.

Documentation for the Text Object Model's properties, methods and classes is available as an RTF. This documentation was created with the ActiveX Documenter (which itself uses a variant of the RichEdit control!).

Click here to download/view the Text Object Model (TOM) method and event documentation

Unfortunately this object model does not seem to have any help text built into it (at least not with the version I currently have). To get more information about the object model and how to use all the objects in it you will need to also take a look at MSDN under this area:

   MSDN Library
      Platform SDK
         User Interface Services
            Windows User Interface
                  Rich Edit Controls
                     Text Object Model

An Overview of the TOM Model
The top-level TOM object is defined by the ITextDocument interface, which has methods for creating and retrieving objects lower in the object hierarchy. For simple, plain text processing, you can obtain an ITextRange object from an ITextDocument object.

If you need to add rich-text formatting, you can obtain ITextFont and ITextPara objects from an ITextRange object.

ITextFont provides the programming equivalent of the Microsoft Word Font dialog box, whilst ITextPara provides the equivalent of the Word Paragraph dialog box. In addition to these three lower-level objects, TOM has a selection object (ITextSelection), which is just an ITextRange object with selection highlighting and additional UI oriented methods. The range and selection objects include screen-oriented methods that enable programs to examine text on the screen or text that could be scrolled onto the screen.

Summarizing these objects in a hierarchical way, we have the following directory tree:

ITextDocument Top-level editing object
   ITextStoryRanges Enumerator for stories in document
   ITextRange Primary text interface: range of text
      ITextFont Character-attribute interface
      ITextPara Paragraph-attribute interface
   ITextSelection Screen highlighted text range that inherits all ITextRange methods
An ITextDocument object describes one or more contiguous ranges of text called stories. In Microsoft Word, stories exist for a number of explicit purposes, such as the main text of a document, headers and footers, footnotes, and annotations. In the rich edit control, there is only one story per document, although a client can use multiple documents to represent multiple stories.

An ITextRange object is defined by its start and end character position (cp) offsets and a story object. As such, it does not exist independently of its parent story object, although its text can be copied to the clipboard or to other targets. A text range object is different from spreadsheet and other range objects, which are defined by other kinds of offsets, like row/column or graphics position (x,y). A text range object can:
  • Modify itself in various ways.
  • Return a duplicate of itself.
  • Copy its start and end character positions and its story pointer to the current selection.
Note that an explicit story object is not needed, since an ITextRange object can always be created to represent any given story. In particular, the ITextDocument object can create an ITextStoryRanges object to enumerate the stories in the document in terms of ranges with start and end cp values that describe complete stories (0 and tomForward).

TopBack to top
Source Code - What We're About!Back to the vbAccelerator RichEdit Control
Source Code - What We're About!Back to ActiveX Control Source Code


About  Contribute  Send Feedback  Privacy

Copyright © 1998-1999, Steve McMahon ( All Rights Reserved.
Last updated: 15 November 1999