Extracting Image from OLE field

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:29
Joined
May 7, 2009
Messages
20,155
the idea came up from this thread:

with old OS and older MS Access, it was done easily.
with New OS and Newer MS Access, it seems it needs more VBA.

all the codes from the sample db was the answer of ChatGPT (I think much wiser than CoPilot).
here are some info from ChatGPT:

1. Structure of an OLE Object Field in MS Access

Types of Data Storage in an OLE Object Field:


  1. Raw Binary Data (Without OLE Header)
    • If you insert an image using ADO or DAO (VBA), the image is stored as pure binary data (BLOB - Binary Large Object).
    • When stored this way, Access does not automatically recognize it as an OLE object unless a compatible application (like MS Paint or MS Word) is used.
  2. OLE Header + Binary Data (With OLE Header)
    • If you insert an image through the Access UI using "Insert Object", Access adds an OLE header and metadata.
    • The header includes:
      • OLE Prefix (metadata that tells Access how to handle the file)
      • CLSID (Class Identifier) (identifies the application used to open the file)
      • Binary image data
    • The result is a larger file size due to the added OLE wrapper.
==
if you need to add more image file type or video, audio or docs (like MS Word, excel, etc.), you can ask ChatGPT for the "magic" header signature and
add it to the code. Note that I am using code for header identification. you can modify the code to put them in Array or much better in a table (next version).

open Form1 and play around with the code.
 

Attachments

the idea came up from this thread:

with old OS and older MS Access, it was done easily.
with New OS and Newer MS Access, it seems it needs more VBA.

all the codes from the sample db was the answer of ChatGPT (I think much wiser than CoPilot).
here are some info from ChatGPT:

1. Structure of an OLE Object Field in MS Access

Types of Data Storage in an OLE Object Field:


  1. Raw Binary Data (Without OLE Header)
    • If you insert an image using ADO or DAO (VBA), the image is stored as pure binary data (BLOB - Binary Large Object).
    • When stored this way, Access does not automatically recognize it as an OLE object unless a compatible application (like MS Paint or MS Word) is used.
  2. OLE Header + Binary Data (With OLE Header)
    • If you insert an image through the Access UI using "Insert Object", Access adds an OLE header and metadata.
    • The header includes:
      • OLE Prefix (metadata that tells Access how to handle the file)
      • CLSID (Class Identifier) (identifies the application used to open the file)
      • Binary image data
    • The result is a larger file size due to the added OLE wrapper.
==
if you need to add more image file type or video, audio or docs (like MS Word, excel, etc.), you can ask ChatGPT for the "magic" header signature and
add it to the code. Note that I am using code for header identification. you can modify the code to put them in Array or much better in a table (next version).

open Form1 and play around with the code.
Sweet... Thanks for sharing....
 

Users who are viewing this thread

Back
Top Bottom