Extract OLE object from table. (1 Viewer)

Poco_90

Registered User.
Local time
Today, 06:26
Joined
Jul 26, 2013
Messages
87
I know this has been asked before but I have hit a :banghead: with my searches.We have an old datalogger that stores data into an access table in OLE format. The field displays "Long Binary Data"

I presume the stored object is some sort of image file as the datalogger software displays a graph after each run and it is this graph I am trying to extract.

I've been trying different code but can't seem to extract the object. One of my searches threw up this site http://www.lebans.com/oletodisk.htm where the developer post a database that extracts the OLE object from the database. Unfortunately when I try to extract the data, I get an error saying "the OLE object contains an unsupported format"

My questions, is there any way to check what type of file is stored and how do I go about extracting it? My ultimate aim is a form displaying all the records where a user can click on a field to view the file.

Thanks in advance,
Poco
 
If using a form, you don't need to extract. The form just shows the picture in a bound picture control.
 
Hi Ranman,
Thanks for the quick response. That doesn't seem to work. Nothing is displayed and when I click on the control I get this message.

"A problem occurs while Microsoft Access was communicating with OLE server or ActiveX control. Close the OLE server and restart it outside of Microsoft Access. then try the original operation again in Microsoft Access."

I attached the properties of the control just in case I have something wrong.
Poco
 

Attachments

  • Capture.PNG
    Capture.PNG
    33.1 KB · Views: 347
The problem is that the OLE function has a "display" helper associated with it. For displays that are J-Peg, Windows Meta Files, Bitmaps, etc., the OLE display helper is part of the Windows Viewer. If the image was created "raw" from some other utility that is not set up in the References or that is not installed to Windows on YOUR machine, you might not be able to see it. Or, if the thing that creates the OLE object doesn't support external viewer calls, you are still stuck.

See what kind of format is involved for the object. If you can't open that file type outside of Access and it is not a native Access file type, odds are that you can't display it.
 
Below is a subroutine I use just to extract the raw binary data of a OLE field. I put comments in it to show where you would need to make changes. You could create a file from one of the OLE fields and then look at the contents of it with something like the HxD Hex Editor. Maybe it would tell you something about its format.


Code:
Public Sub OutputBLOB(FilePath As String)

Dim fd As DAO.Field2
Dim FileNumber As Long
Dim OutputArray() As Byte
Dim FileSize As Long
Dim rs As DAO.Recordset

If Len(Dir(FilePath)) > 0 Then
    Exit Sub
End If
[COLOR="green"]'Replace tblIcon with table or query name[/COLOR]
Set rs = CurrentDb.OpenRecordset("tblIcon")
[COLOR="green"]'replace IconBmp with field name[/COLOR]
Set fd = rs.Fields("IconBmp")
ReDim OutputArray(fd.FieldSize - 1)
OutputArray = fd.GetChunk(0, fd.FieldSize)
FileNumber = FreeFile
Open FilePath For Binary As FileNumber
Put FileNumber, , OutputArray
Close FileNumber
rs.Close

End Sub
 
Doc Man, Sneuberg,
Thank you for getting back to me. I could be snookered alright as the application creates the image on the fly and stores it into the table. In the application you can view the file but I was hoping to do it outside of the application. The application is very customized and stores the data into a HTE file, so I rename it to MDB to access the tables.

Sneuberg I will try your code and see how I get on. Hopefully I will discover a file type that I can reference.
Thanks again,
Poco
http://www.access-programmers.co.uk/forums/member.php?u=135192
 
Sneuberg,
Can you tell me how I can create a file from your code? I am not sure how I should use it. I inserted it into a module and tried to call it using an event procedure, but had no luck.
thanks
Poco
 

Users who are viewing this thread

Back
Top Bottom