Export OLE Object as JPG

  • Thread starter Embarrassed Bears Fan
  • Start date
E

Embarrassed Bears Fan

I have a table of about 700 records. One field contains
a picture saved as an OLE Object. I want to get rid of
this field and replace it with a new field that stores a
JPG filename of the resultant exported OLE Object that
was previously saved there. Is this possible and how?
The first step would be to systemmatically export the OLE
Obj to a default directory and save it under a
corresponding default picture name like <PrimaryKey>.jpg
The next step would be a massive update on the table
itself. I can handle the second step but am struggling
finding a means of achieving the first step. Thanks in
advance.
 
J

John Nurick

Hi,

The only simple way of handling objects in Access OLE fields is with a
form bound to the table in question and an objectframe control on the
form bound to the OLE field.

As far as I can remember (it's late at night and past my bedtime<g>) you
then need to write VBA code that iterates through the table, using the
Action and/or Verb properties of the objectframe to launch the object in
a VBA-enabled graphics program. From there, on a good day, you can use
Automation to control the graphics program to convert the image to a
jpeg (if necessary), save it where you want, and store the results.

PS: what's embarrasing about bears?
 
E

Exponent

It's possible to export images saved this way by rendering the object to a metafile then re-encoding the
image.

You'll find a sample at www.lebans.com and there's further info in the MS KB.

What is the 'massive' table update ? you just need to delete the OLE Object field. No need for an extra
field to store the filename when they are named using the PK.

Note that this approach is 'lossy' due to the additional jpeg encoding pass, and that metadata such as
exif will be lost, but this is usually unavoidable after using OLE Embedding.

For storing images actually inside the database it's almost always better to use raw-binary storage. This
avoids the problems of overhead/bloat, extraction/data-portability, OLE Server issues when viewing etc.
 

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