ITextDocument interface

The ITextDocument interface is the Text Object Model (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 an ITextStoryRanges story enumerator.
When to Implement

Applications typically do not implement the ITextDocument interface. Microsoft text solutions, such as rich edit controls, implement ITextDocument as part of their TOM implementation.

When to Use

Applications can retrieve an ITextDocument pointer from a rich edit control. To do this, send an EM_GETOLEINTERFACE message to retrieve an IRichEditOle object from a rich edit control. Then, call the object's IUnknown::QueryInterface method to retrieve an ITextDocument pointer.


The ITextDocument interface has these methods.

Method Description
ITextDocument::BeginEditCollection Turns on edit collection (also called undo grouping).
ITextDocument::EndEditCollection Turns off edit collection (also called undo grouping).
ITextDocument::Freeze Increments the freeze count.
ITextDocument::GetDefaultTabStop Gets the default tab width.
ITextDocument::GetName Gets the file name of this document. This is the ITextDocument default property.
ITextDocument::GetSaved Gets a value that indicates whether changes have been made since the file was last saved.
ITextDocument::GetSelection Gets the active selection.
ITextDocument::GetStoryCount Gets the count of stories in this document.
ITextDocument::GetStoryRanges Gets the story collection object used to enumerate the stories in a document.
ITextDocument::New Opens a new document.
ITextDocument::Open Opens a specified document. There are parameters to specify access and sharing privileges, creation and conversion of the file, as well as the code page for the file.
ITextDocument::Range Retrieves a text range object for a specified range of content in the active story of the document.
ITextDocument::RangeFromPoint Retrieves a range for the content at or nearest to the specified point on the screen.
ITextDocument::Redo Performs a specified number of redo operations.
ITextDocument::Save Saves the document.
ITextDocument::SetDefaultTabStop Sets the default tab stop, which is used when no tab exists beyond the current display position.
ITextDocument::SetSaved Sets the document Saved property.
ITextDocument::Undo Performs a specified number of undo operations.
ITextDocument::Unfreeze Decrements the freeze count.


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header tom.h

See Also


Text Object Model

Using The Text Object Model