home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / OleWord1 / Main.pas < prev    next >
Pascal/Delphi Source File  |  1998-03-14  |  829b  |  43 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     Button1: TButton;
  12.     procedure Button1Click(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18.  
  19. var
  20.   MainForm: TMainForm;
  21.  
  22. implementation
  23.  
  24. uses ComObj;   // Declares the CreateOleObject function
  25.  
  26. {$R *.DFM}
  27.  
  28. { This procedure works with Microsoft Word 95 and
  29.   earlier versions. It does *not* work with the
  30.   newer Word 97, which now uses Visual Basic in
  31.   place of Word Basic. }
  32. procedure TMainForm.Button1Click(Sender: TObject);
  33. var
  34.   V: Variant;
  35. begin
  36.   V := CreateOleObject('Word.Basic');
  37.   V.Insert('Hello from Delphi');
  38.   V.FilePrint;
  39.   V.FileSaveAs('C:\Hold.doc');
  40. end;
  41.  
  42. end.
  43.