这是一个可以存word 文件和读word 文件 代码你可以看看 ,保存work文件的字段类型是(image)<br>procedure TF_PFSJCXTJ.N1Click(Sender: TObject);<br>var<br> I : integer;<br> MemoryStream:TMemoryStream;<br>begin<br> MemoryStream:=TMemoryStream.Create;<br> try<br> if opendialog1.Execute then<br> begin<br> opendialog1.Filter:='*.doc';<br> MemoryStream.LoadFromFile(opendialog1.FileName);<br> end<br> else exit;<br> try<br> if DbGrid1.SelectedRows.Count >1 then<br> begin<br> for I := 0 to DbGrid1.SelectedRows.Count -1 do<br> begin<br> DBGrid1.DataSource.DataSet.GotoBookMark(Pointer(DBGrid1.Selectedrows.Items));<br> QRSDOC.Close;<br> QRSDOC.SQL.Clear;<br> QRSDOC.SQL.Add('update Item_batch set item_doc2=:cs_doc2 where Item_batchno=:cs_batchno');<br> QRSDOC.Parameters.ParamByName('cs_batchno').Value:=dbGrid1.DataSource.DataSet.FieldByName('Item_batchno').AsString;<br> QRSDOC.Parameters.ParamByName('cs_doc2').LoadFromStream(MemoryStream,ftgraphic);<br> QRSDOC.ExecSQL;<br> end;<br> showmessage('保存DOC文件成功!');<br> end<br> else<br> begin<br> QRSDOC.Close;<br> QRSDOC.SQL.Clear;<br> QRSDOC.SQL.Add('update Item_batch set item_doc2=:cs_doc2 where Item_batchno=:cs_batchno');<br> QRSDOC.Parameters.ParamByName('cs_batchno').Value:=dbGrid1.DataSource.DataSet.FieldByName('Item_batchno').AsString;<br> QRSDOC.Parameters.ParamByName('cs_doc2').LoadFromStream(MemoryStream,ftgraphic);<br> QRSDOC.ExecSQL;<br> showmessage('保存DOC文件成功!');<br> end;<br> dbGrid1.DataSource.DataSet.Refresh;<br> except<br> end;<br> finally<br> MemoryStream.Free;<br> end;<br>end;<br><br>procedure TF_PFSJCXTJ.DOC2Click(Sender: TObject);<br>var<br> TempMemory:TStream;<br> Memory:TMemoryStream;<br> fname:string;<br> a:OleVariant;<br>begin<br> try<br> QRSDOC.CLOSE;<br> QRSDOC.SQL.CLEAR;<br> QRSDOC.SQL.ADD('select item_doc2 from Item_batch where Item_batchno=:cs_batchno');<br> QRSDOC.Parameters.ParamByName('cs_batchno').Value:=dbGrid1.DataSource.DataSet.FieldByName('Item_batchno').AsString;<br> QRSDOC.OPEN;<br> fname:='c:/3.doc';<br> QRSDOC.Edit;<br> Memory:=TMemoryStream.Create;<br> TempMemory:=QRSDOC.CreateBlobStream(QRSDOC.fieldbyname('item_doc2'),bmReadWrite);<br> Memory.CopyFrom(TempMemory,TempMemory.Size);<br> Memory.SaveToFile(fname);<br> a:=fname;<br> WordApplication1.Connect;<br> WordApplication1.Visible:=true;<br> WordDocument1.Connectto(WordApplication1.Documents.Open(a,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam));<br> WordApplication1.Disconnect;<br> finally<br> Memory.Free;<br> end;<br><br>end;