Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

Spell Checking from Delphi code using MS Word - Office Automation in Delphi

By Zarko Gajic, About.com

4 of 7

The Spell Check Project - TWordApplication, TWordDocument

The Spell Project at Design-Time

The Spell Project at Design-Time

To build a spell checking project we'll need two forms: one used to edit the text and the other to see the spelling suggestions... but, let's go from the beginning.

Start Delphi. Create a new project with one blank form (form1, by default). This will be the main form in the spell checking with MS Word project. Add one TMemo (Standard tab) and two TButtons to the form. Add some text to the Memo filling the Lines property. Of course, with some typo errors. Select the Servers tab and add TWordApplication and TWordDocument to the form. Change the name of TWordApplication component from WordApplication1 to WordApp, WordDocument1 to WordDoc.

TWordApplication, TWordDocument

When automating Word, we use properties and methods of the Application object to control or return application­ wide attributes, to control the appearance of the application window, and to get to the rest of the Word object model.

The published property ConnectKind is used to control whether we connect to a newly launched Word instance or to an existing instance that is already running. Set ConnectKind to ckRunningInstance.

When we open or create a file in Word, we create a Document object. A common task when using automating Word is to specify an area in a document and then do something with it, such as insert text and spell check it. An object that represents a contiguous area in a document is called Range.

Explore Delphi Programming

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Advanced Delphi Techniques
  5. OLE / COM / Automation
  6. Automation
  7. Spell Checking from Delphi code using MS Word - Word Automation in Delphi

©2009 About.com, a part of The New York Times Company.

All rights reserved.