简体   繁体   中英

Microsoft Access 2016 OLE Object & Binary export

I'm trying to write some VBA code to generate a text file containing SQL INSERT statements for all records in a table in an Access database (accdb). The table has an OLE Object field and a Binary field. I can't seem to get them written to the text file properly; I mostly get question marks(?). I've search for solutions and found some possible ideas but none worked.

If any one has suggestions, I will be very appreciative of any help that you can provide.

Miguel

I actually found an solution following some more searching:

Function ByteArrayToHex(B() As Byte) As String
    Dim n As Long, I As Long
    
    ByteArrayToHex = Space$(2 * (UBound(B) - LBound(B)) + 2)
    n = 1
    For I = LBound(B) To UBound(B)
       Mid$(ByteArrayToHex, n, 2) = right$("00" & Hex$(B(I)), 2)
       n = n + 2
    Next
    ByteArrayToHex = "0x" & ByteArrayToHex
End Function

Michael

To export OLE objects in a Microsoft Access file, open this file with the Access application and create a corresponding form with all relevant fields. Use the VBA code provided in the link and you should be able to export some of the most common file types in an automated fashion. Good luck. https://medium.com/@haggenso/export-ole-fields-in-microsoft-access-c67d535c958d

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM