给你demo的代码,已经测试完毕。如果还不行的话告诉我E-Mail,我发给你。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls, Word2000, OleServer;<br><br>type<br> TForm1 = class(TForm)<br> WordApplication1: TWordApplication;<br> Button1: TButton;<br> Button2: TButton;<br> OpenDialog1: TOpenDialog;<br> ADOConnection1: TADOConnection;<br> ADOQuery1: TADOQuery;<br> DataSource1: TDataSource;<br> DBGrid1: TDBGrid;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> m_File:TMemoryStream;<br>begin<br> if OpenDialog1.Execute then<br> begin<br> m_File:=TMemoryStream.Create;<br> m_File.LoadFromFile(OpenDialog1.FileName);<br> ADOQuery1.Append;<br> TBlobField(ADOQuery1.FieldByName('文件')).LoadFromStream(m_File);<br> try<br> ADOQuery1.Post;<br> finally<br> m_File.Free;<br> end;<br> end;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br> Template : OleVariant;<br> NewTemplate : OleVariant;<br> DocuType : OleVariant;<br> Visible : OleVariant;<br>begin<br> if ADOQuery1.IsEmpty then<br> begin<br> ShowMessage('当前数据库为空!');<br> end<br> else<br> begin<br> TBlobField(ADOQuery1.FieldByName('文件')).SaveToFile('C:/temp.doc');<br> WordApplication1.Connect;<br> WordApplication1.Visible:=True;<br> Template:='C:/temp.doc';<br> NewTemplate:=False;<br> DocuType:=0;<br> Visible:=True;<br> try<br> //WordApp.Documents.Add(Template:='C:/Doc1.dot',NewTemplate:=False,DocuType,Visible);<br> WordApplication1.Documents.Add(Template,NewTemplate,DocuType,Visible);<br> except<br> showmessage('打开文档失败!');<br> end;<br> end;<br>end;