home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / OleWord2 / Main.pas < prev    next >
Pascal/Delphi Source File  |  1998-03-14  |  918b  |  47 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 the newer Word 97,
  29.   which uses Visual Basic in place of the standard
  30.   Word Basic as its controlling language. }
  31. procedure TMainForm.Button1Click(Sender: TObject);
  32. var
  33.   V, X: Variant;
  34.   S: String;
  35. begin
  36.   V := CreateOleObject('Word.Document');
  37.   X := V.Range(0, 0);
  38.   X.InsertBefore('Hello from Delphi');
  39.   X.Font.Name := 'Arial';
  40.   X.Font.Size := 18;
  41.   X.InsertParagraphAfter;
  42.   V.Printout;
  43.   V.SaveAs('C:\Hold.doc');
  44. end;
  45.  
  46. end.
  47.