unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Word2000, OleServer;
type
TForm1 = class(TForm)
WordApplication1: TWordApplication;
WordDocument1: TWordDocument;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure OpenWordFile(FileName:String);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
openwordfile(ExtractFilePath(Application.ExeName)+'doc/1.doc');
end;
procedure TForm1.OpenWordFile(FileName: String);
var
a:OleVariant;
begin
a:=filename;
WordApplication1.Connect;
WordApplication1.Visible:=true;
WordDocument1.Connectto(WordApplication1.Documents.Open(a,EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,EmptyParam));
end;
end.
d6+office2003编译通过!!
记得给分哦.呵呵..