还有一段转载的程序如下:
procedure TMainForm.NewMenuClick(Sender: TObject);
begin
MainPage.ActivePage := EditSheet;
MyWord:= CoApplication_.Create;
FileName := 'C:/My Documents/HHH.doc';
MyWord.Documents.Open(FileName,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam);
OleContainer1.DoVerb( ovShow );
end;
procedure TMainForm.CloseMenuClick(Sender: TObject);
var
OleStream : TMemoryStream;
begin
OleStream := TMemoryStream.Create;
Myword._Release;
OleContainer1.SaveToStream( OleStream );
OleStream.Position := 0;
with dm1.InsertTable do
begin
Close;
Open;
Edit;
//Append;
FieldByName( 'title' ).asstring := 'ok,letgo';
TBlobField( fieldbyname('ole') ).LoadFromStream( OleStream );
post;
begin
dm1.db2.StartTransaction;
try
ApplyUpdates; {try to write the updates to the database};
dm1.Db2.Commit; {on success, commit the changes};
except
dm1.Db2.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;
//ApplyUpdates;
showmessage( 'done' );
end;
OleStream.Free;
end;