--George
Loading from a temp file is the best you can get if you use Word.
Oliver Townshend
--
With best regards, Mike Shkolnik
EMail: mshk...@scalabium.com
http://www.scalabium.com
"GW" <georg...@justice.com> сообщил/сообщила в новостях следующее:
news:3ee4d793$1...@newsgroups.borland.com...
"GW" <georg...@justice.com> wrote in message
news:3ee4d793$1...@newsgroups.borland.com...
"Mike Manning" <NOMOR...@nowhere.com.au> wrote in message
news:3ee5c738$1...@newsgroups.borland.com...
--George
"Mike Shkolnik" <mshkol...@ukr.net> wrote in message
news:3ee5...@newsgroups.borland.com...
Yes, MSWord cannot load it's document from any place, but the file.
But!
I solved problem, getting different point of view on it.
I needed to Hold documents in a database, but their sources(originals) are
word files.
So I read them and put in the database, so I can read them back later.
Here you are some code illustrating my words, because my English is too bad
:
Assume that:
"OLE1" is an OLEContainer.
===== 1 ====== Opening DOC file and saving it into database :
procedure TfrmMain.DocFileImport(aFileName: String; Qry: TQuery);
var
BlobMemStream:TMemoryStream;
.....
begin
OLE1.CreateObjectFromFile(aFileName,false);
OLE1.Close;
BlobMemStream:=TMemoryStream.Create;
OLE1.SaveToStream(BlobMemStream);
BlobMemStream.Seek( 0, soFromBeginning);
With uQry do
begin
Close;
SQL.Text := 'INSERT INTO MyTable VALUES ( :docBody)';
ParamByName(aParamName).LoadFromStream(aStream, ftBlob);
ExecSQL;
FreeAndNil(BlobMemStream);
end;
end;
===== 2 ====== Loading DOC from database in OLEContainer :
Procedure LoadDatabaseDoc( Qry : TQuery);
Var
MemBlobStream : TStream;
begin
With Qry do
begin
Close;
SQL.Text := 'SELECT docBody FROM MyTable';
Open;
try
try
MemBlobStream:=Qry.CreateBlobStream(Qry1.FieldByName('advTemplateBody'),bmRe
ad);
MemBlobStream.Seek( 0, soFromBeginning);
OLE1.LoadFromStream( MemBlobStream);
finally
FreeAndNil( MemBlobStream);
end;
finally
Close;
end;
end;
In other words, you save OLEContainer's content to stream which is OLE
Header + OLE Document, which gives you ability to load it later. Word as an
application cannot load document from stream, but OLEContainer can read any
ole object data and construct ole object depending on data. (of course OLE
Server must present in order to edit document e.g. you must have Word
installed on the computer which need to run your program if program requires
document editing).
Hope, it will help you,
Marin
"GW" <georg...@justice.com> wrote in message
news:3ee4d793$1...@newsgroups.borland.com...