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

2 of 7

Connecting to Word: "Hello Word" Early Binding vs. Late Binding

There are several main steps and three main ways to automate Word from Delphi.

Delphi >= 5 - Office XX Server Components

If you are the owner of Delphi version 5 and up, you can use the components located on the Servers tab of the component palette to connect and control the Word. Components like TWordApplication and TWordDocument wrap the interface of Word exposed objects.

Delphi 3,4 - Early Binding

Speaking in terms of Automation, in order for Delphi to access methods and properties exposed by MS Word the Word type library must be installed. Type libraries provide the definitions for all methods and properties that are exposed by an Automation Server.

To use Word's type library in Delphi (version 3 or 4) select the Project | Import Type Library… menu and choose the file msword8.olb located in Microsoft Office's "Office" directory. This will create the file "Word_TLB.pas" which is the object pascal translation of the type library. Include Word_TLB in the uses list of any unit that will be accessing Word properties or methods. Referencing Word methods using the type library is called early binding.

Delphi 2 - Late Binding

To access Word objects without the use of type libraries (Delphi 2) an application can use, so called, late binding. Late binding should be avoided, if possible, since it's much easier and faster to use type libraries - the compiler helps by catching errors in the source. When using late binding Word is declared to be a variable of Variant type. This in particular means than to call methods and access properties you must know what they are.

Explore Delphi Programming

About.com Special Features

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 - Office Automation in Delphi

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

All rights reserved.