How to save the OLE Object into their respective file?

S

Shelby

Hi,

I have an Access with one of the field set to OLE Object.
That field may contain "Picture", "MS Word", "MS Powerpoint" etc.

Now I would like to save all those content into their respective file. That
means I do not want to embed the file in Access anymore. I want to store
them as a file.

I was thinking of doing an exe programe to do the job. There are about 500
records.

I tried using the ADODB.Stream object to write the binary into a file but i
didn't get what I want. For word file, what I get are all chunk data. For
picture, I can't even open the file. When I try to open up the Access and do
a Copy ole object and Paste onto my desktop, I get a Scrap file which I
can't open.


Seems like the only way to see the file is through the Access Forms.
Is there no way that I can get back the actual content into their respective
file anymore?
 
D

Dirk Goldgar

Shelby said:
Hi,

I have an Access with one of the field set to OLE Object.
That field may contain "Picture", "MS Word", "MS Powerpoint" etc.

Now I would like to save all those content into their respective
file. That means I do not want to embed the file in Access anymore. I
want to store them as a file.

I was thinking of doing an exe programe to do the job. There are
about 500 records.

I tried using the ADODB.Stream object to write the binary into a file
but i didn't get what I want. For word file, what I get are all chunk
data. For picture, I can't even open the file. When I try to open up
the Access and do a Copy ole object and Paste onto my desktop, I get
a Scrap file which I can't open.


Seems like the only way to see the file is through the Access Forms.
Is there no way that I can get back the actual content into their
respective file anymore?

Stephen Lebans has code on his web site, www.lebans.com, to save OLE
fields to bitmap and JPEG files. I don't know if he has a general
solution there, but it would be a good place to start.
 
S

Stephen Lebans

Your best best is to write a small VBA routine to use Automation to:
1) Check the Bound OLE Frame control's OLE class name
2) Instantiate the matching APP object
3) Set the App object to the OLE objects "object" interface
4) Invoke the SaveAs method(Identical in all of the Office apps you
named I believe").
5) Loop through the rest of the recordset.

Shouldn't take more than 20 lines of code in total.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
S

Shelby

Hi Stephen Lebans,


I have tried doing up a VBA but to no avail too.
The class name returns me "StaticDib" or even nothing for some.

Shelby
 
S

Shelby

Hi,

I have downloaded DownloadFiles/ExportOLEtoJpegVer16.zip (OLEToDisk) and
tried the programe but to no avail too.
Everything was fine until I click Export button. Error was : IJL Error:
[-10] - Failed to save to JPG.

Shelby
 
S

Stephen Lebans

My solution will only work for Image file types. The error you are
seeing usually happens when you do not follow the instructions on
supplying a valid field name for the output files. Go back to STEP #4
and make sure that the field you select only contains text will no
illegal characters for the outfile filename.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Shelby said:
Hi,

I have downloaded DownloadFiles/ExportOLEtoJpegVer16.zip (OLEToDisk) and
tried the programe but to no avail too.
Everything was fine until I click Export button. Error was : IJL Error:
[-10] - Failed to save to JPG.

Shelby

"Stephen Lebans"
 
S

Stephen Lebans

For any Office documents you inserted:
If you cannot get it from the OLE Frame control's exposed props then you
will have to go into the OLE Object itself. If I remember, something
like:
Me.NameOfOLEFrameControl.Object.Application.Value
Just set a break point and examine the Object properties.

Now you'll have to seperate out the Office apps that inserted the
objects versus anything else. I have never seen "StaticDIB" as an OLE
class name. DIB is simply a packed Bitmap and is easily copied to a disk
file. What program did you use to insert the original image?

I am leaving tomorrow morning and will not be near a computer until late
Sunday night.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
J

Jim Vierra

Make the object attach to a database field of type object. Use the interface
to use the associated program save the object to a file.

If it's Word, you can get the application reference from the object and call
the save method. There used to be one good example in Access XP/2002 Help.
I haven't done this for a couple of years so I'm going from memory.
 
A

Alex Ivanov

You basically need to strip ole header from the blob and save the rest of
the field into a file. This is little complicated, because ole header is not
of constant width. This MS article may help you to figure out how to do
that, at least it gives a layout of Access OLE headers.
http://support.microsoft.com/kb/q147727/
 
S

Stephen Lebans

StaticDIB is a an OLE doc type where the rendering is performed by the
OLE Handler directly in the OLE 2 DLL. No outside OLE Server is
required.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
E

Esther McMillen

Shelby said:
Hi,

I have an Access with one of the field set to OLE Object.
That field may contain "Picture", "MS Word", "MS Powerpoint" etc.

Now I would like to save all those content into their respective file.
That means I do not want to embed the file in Access anymore. I want to
store them as a file.

I was thinking of doing an exe programe to do the job. There are about 500
records.

I tried using the ADODB.Stream object to write the binary into a file but
i didn't get what I want. For word file, what I get are all chunk data.
For picture, I can't even open the file. When I try to open up the Access
and do a Copy ole object and Paste onto my desktop, I get a Scrap file
which I can't open.


Seems like the only way to see the file is through the Access Forms.
Is there no way that I can get back the actual content into their
respective file anymore?
 
B

Bonno Hylkema

Dear Stephen,

I am trying to figure out your 20 lines solution through Automation.

If I insert in the OLE field of a table a Word document, the following line
of code shows me the name of the application:
Me.NameOfOLEFrameControl.Object.Application.Name shows "Microsoft Word". So
that is nice.

If I insert a Paint bitmap the same line of code gives an error: VB error
2774 "Automation is not supported by this object". Does it looks like you
can not use Automation in conjunction with Paint? You can't set any
reference to a Paint library either. Does it mean that I had have to use the
Clipboard or GetChunk hacks to save a bitmap file?

I am a bit stuck on this matter. Maybe you can help me. An example of a 20
lines solution for saving Paint bitmaps would be great.

Thanks in advance, Bonno Hylkema
 
S

Stephen Lebans

Bonno as I stated in my initial reply the use of Automation would be
restricted to Office documents. The Paint Bitmap was inserted by MS
Paint which does not expose its workings via Automation.
As you said, you will have to use the Clipboard or direct reading of the
Binary data to extract the Bitmap.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
E

Esther McMillen

Shelby said:
Hi,

I have an Access with one of the field set to OLE Object.
That field may contain "Picture", "MS Word", "MS Powerpoint" etc.

Now I would like to save all those content into their respective file.
That means I do not want to embed the file in Access anymore. I want to
store them as a file.

I was thinking of doing an exe programe to do the job. There are about 500
records.

I tried using the ADODB.Stream object to write the binary into a file but
i didn't get what I want. For word file, what I get are all chunk data.
For picture, I can't even open the file. When I try to open up the Access
and do a Copy ole object and Paste onto my desktop, I get a Scrap file
which I can't open.


Seems like the only way to see the file is through the Access Forms.
Is there no way that I can get back the actual content into their
respective file anymore?
 
A

Alex Ivanov

This sample seems to be able to extract Word docs, PowerPoint, Bitmaps, and
some other types of files.
It does not work with objects created by Microsoft Photo Editor as it seems
it stores the embedded data
as "Compound Files", but it can't open such a file if it is extracted into a
regular file. May be some of you can enlighten me on this issue?
It does not work with Excel I think for similar reason.

http://www.aleksoft.net/samples/oleobject.bas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top