以下语句可以实现
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtnrs, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Word1: TMenuItem;
OleContainer1: TOleContainer;
New1: TMenuItem;
Save1: TMenuItem;
Exit1: TMenuItem;
procedure New1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.New1Click(Sender: TObject);
begin
self.OleContainer1.CreateObject('word.document',true);
self.OleContainer1.DoVerb(OvShow);
end;
procedure TForm1.Save1Click(Sender: TObject);
begin
self.OleContainer1.SaveAsDocument('test.doc');
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Application.Terminate;
end;
end.