(page requirements)

Hello, word!

OLE automation servers are a natural part of most major Microsoft applications such as Microsoft Office products and many other popular applications, which means you can control them from your application almost as if they were a part of your program.

For example, let's take Microsoft Word 95. As you can see, it'll only take a few lines of code to make it possible to insert text to Word documents from your application (don't forget to add "OLEAuto" unit to your "uses" statement):

procedure InsertTextToWord(
  sText : string );
var  W : Variant;
begin
  { create an OLE object of           }
  { type Word.Basic                   }
  W := CreateOleObject( 'word.basic' );
  { call Word.Basic's Insert function }
  W.Insert( sText );
end;

Using the above function, all you have to do is call it with the text you want to insert:

InsertTextToWord( 'hello, word!' );

To find out what other commands you can use to control Microsoft Word (for example) lookup its help for "WordBasic" -- the name of the macro language used to write custom applications for Word. To find out if your favorite application supports OLE automation, lookup its help for "OLE Automation."

 
 
Applicable Keywords : Delphi, Delphi 2.x, Functions, MS Word, Win32, WordBasic
 
 
 
Copyright © 2009 Chami.com. All Rights Reserved. | Advertise | Created in HTML Kit editor