1、存入
procedure TForm1.Button1Click(Sender: TObject);
var
CurST:TStringStream;
Filename:string;
begin
if OpenDialog1.Execute then
begin
Filename:=OpenDialog1.FileName;
wordOleContainer.CreateObjectFromFile(FileName, False);
CurST := tstringstream.create('');
wordOleContainer.savetostream(CurST);
ADOTable1.Append;
ADOTable1.FieldByName('doc').AsVariant:=CurST.datastring;
ADOTable1.Post;
CurST.free;
wordOleContainer.DestroyObject;
end; }
end;
//读出
procedure TForm1.BitBtn1Click(Sender: TObject);
var
CurItemStream:TStringStream;
CurItem:Variant;
begin
CurItem:=aDOTable1.FieldByName('doc').AsVariant;
CurItemStream:= TStringstream.create(CurItem);
CurItemStream.position:=0;
wordOleContainer.loadfromstream(CurItemStream);
CurItemStream.free;
wordOleContainer.SaveAsDocument('temp.rtf');
wordOleContainer.DestroyObject;
sleep(5000);
richedit1.lines.loadfromfile('temp.rtf');//此处读出rtf可能是乱码,请查看delphi
//richedit demo
end;