WBread
asked on
Load a TOleContainer from a stream which contains a file image, without using CreateObjectFromFile
Hi,
I have a database which contains blobs loaded from file of various MS doc types such as Word and Excel. I'm trying to load these into a TOleContainer in much the same way that CreateObjectFromFile() works, however, without having to write the contents out to disk, etc. I've tried a number of combinations to no avail. Below is a code snippet which may at least help in conveying what I am trying to accomplish.
Any help would be greatly appreciated!
...
try
Stream:=TMemoryStream.Crea te; {Creation memory stream and saving content from database}
TBlobField(FDataLink.Field ).SaveToSt ream(Strea m);
Stream.Seek(0,soFromBeginn ing);
S := GetAssociatedClassname(Ext ractFileEx t(aOrigina lFileName) ); // Returns, for example, "Excel.Sheet.8" or "Word.Document.8"
CreateObject(S, False);
// LoadFromStream(Stream); // doesn't work!!!! ...Invalid Stream format
if Assigned(Stream) then
begin
Stream.Free;
Stream:=nil;
end;
except
on E:exception do begin
if Assigned(Stream) then Stream.Free;
Raise;
end;
end;
...
I have a database which contains blobs loaded from file of various MS doc types such as Word and Excel. I'm trying to load these into a TOleContainer in much the same way that CreateObjectFromFile() works, however, without having to write the contents out to disk, etc. I've tried a number of combinations to no avail. Below is a code snippet which may at least help in conveying what I am trying to accomplish.
Any help would be greatly appreciated!
...
try
Stream:=TMemoryStream.Crea
TBlobField(FDataLink.Field
Stream.Seek(0,soFromBeginn
S := GetAssociatedClassname(Ext
CreateObject(S, False);
// LoadFromStream(Stream); // doesn't work!!!! ...Invalid Stream format
if Assigned(Stream) then
begin
Stream.Free;
Stream:=nil;
end;
except
on E:exception do begin
if Assigned(Stream) then Stream.Free;
Raise;
end;
end;
...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have tried getting that result but was not able to find it. I added the GetVerb(...) to have something similar...
Regards Jacco
Regards Jacco
ASKER
This works great. Thanks!!
I'm still trying to figured out how to make the document show up in the "viewing" mode, i.e. visible but without the toolbars/menus, that I initially see using CreateObjectFromFile. If you happen to know this, I'd be glad to see it :)
Either way, this answer is complete and very welcome.
Thanks again
-Todd