chami.com/tips/
Last  Home  Next
 Internet
 Programming
 Windows


Click for details
Keywords
Delphi 2.x
Delphi
Functions
MS Word
Win32
WordBasic

Hello, word!

    See Also
  How to call Internet Explorer from Delphi

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."

 
Related Links Email Print 
Created on 15-Jan-1997. Source code colorized using CodeColorizer.
Copyright (C) 1996-99 Chami.com All Rights Reserved. Reproduction in whole or in part
or in any form or medium without express written permission of Chami.com is prohibited.
Information on this page is provided as-is without warranty of any kind. Use at your own risk.
Free Downloads | Products & Services | Privacy Statement | Terms & Conditions | Advertising Info