I am developing code to take documents stored as OLE objects in the database and save them all to file. We have a mix of PDFs, Word documents, Excel documents, TIFFs and various other files. I have developed code to handle all documents other than Word/Excel without needing to activate an OLE control or OLE object but for Word and Excel I seem to be forced to use an OLE Control which means a lot of flashing… Here is my technique for non Office documents: Write blob out to file as scratch.ole file Open file in to an OLEStorage object Based on the original file type if it is PDF use a OLEStream label of ‘CONTENTS’ otherwise use a label of char(1)+’Ole10Native’ (How yucky is that!) Open the stream based on the OLEStorage/Label Read the OLEHeader block from the stream and based on the file type determine the starting position and length of the data. Dump this data to file. For Office documents, I open an OLEControl and load the document into that using objectdata assignment. I then activate the document OffSite! (InPlace! Does not seem to work with SaveAs) and then call the object saveas method. E.g. l_ole_pointer.object.application.ActiveDocument.saveas(ls_save_filename) So here are my challenges: 1) I would love to be able to extract the word document from the stream directly with OLE Activation but if I have a complex word document that has embedded OLE objects then there are multiple OLE streams and it gets nasty – simple documents I can handle… OR 2) Use OLEAutomation using an OLEObject but I cannot figure out how to load an OLEObject from a blob – there is no equivalent to OLEControl.objectdata=lblb_blob OR 3) Use an OLEControl but activate InPlace! – I cannot get the saveas method to work for Office document when I do this. Any Ideas? Thanks, Mark
↧